|
@@ -0,0 +1,305 @@
|
|
|
+
|
|
|
+// evaluation()
|
|
|
+function evaluation() {
|
|
|
+ var a = 5
|
|
|
+ var b, c
|
|
|
+ b = (a * 5)
|
|
|
+ b = (c = (b/2))
|
|
|
+
|
|
|
+ console.log(a, b, c)
|
|
|
+}
|
|
|
+
|
|
|
+// error()
|
|
|
+function error() {
|
|
|
+ let a = 10
|
|
|
+ alert(a)
|
|
|
+ (() => a++)()
|
|
|
+ alert(a)
|
|
|
+}
|
|
|
+
|
|
|
+// mistake()
|
|
|
+function mistake() {
|
|
|
+ let a = 1
|
|
|
+ let b = 2
|
|
|
+ if (a)
|
|
|
+ {
|
|
|
+ alert('a')
|
|
|
+ } else;
|
|
|
+ if (b) {
|
|
|
+ alert('b')
|
|
|
+ }
|
|
|
+ // выполняет второй иф вне зависимости от значения первого
|
|
|
+}
|
|
|
+
|
|
|
+// age()
|
|
|
+function age() {
|
|
|
+ const result = prompt('сколько лет?')
|
|
|
+ if (result) {
|
|
|
+ const currentYear = new Date()
|
|
|
+ const birthYear = currentYear.getFullYear() - result
|
|
|
+ alert(birthYear)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// temperature()
|
|
|
+function temperature() {
|
|
|
+ const celsium = prompt('вводи градусы цельсия')
|
|
|
+ if (celsium) {
|
|
|
+ const faren = celsium * 1.8 + 32
|
|
|
+ alert(faren)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// divide()
|
|
|
+function divide() {
|
|
|
+ const a = prompt('вводи делимое')
|
|
|
+ const b = prompt('вводи делитель')
|
|
|
+ if (a && b) {
|
|
|
+ alert(Math.floor(a / b))
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// odd()
|
|
|
+function odd() {
|
|
|
+ const res = prompt('вводи число')
|
|
|
+ if (res) {
|
|
|
+ const num = Number(res)
|
|
|
+ if (Number.isNaN(num)) {
|
|
|
+ alert('введи ЧИСЛО')
|
|
|
+ } else {
|
|
|
+ if (num % 2) {
|
|
|
+ alert('НЕЧЕТНОЕ')
|
|
|
+ } else {
|
|
|
+ alert('ЧЕТНОЕ')
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// greeting()
|
|
|
+function greeting() {
|
|
|
+ const res = prompt('пиши имя')
|
|
|
+ if (res) {
|
|
|
+ alert(`Prived ${res}`)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// lexics()
|
|
|
+function lexics() {
|
|
|
+ const vargas = ["варгас", "вазген", "вагинализ", "вракес", "варган", "нормес"]
|
|
|
+ const str = prompt('пиши текст')
|
|
|
+ if (str) {
|
|
|
+ const lowerStr = str.toLowerCase()
|
|
|
+ const res = vargas.some((element) => lowerStr.includes(element) )
|
|
|
+ if (res) {
|
|
|
+ alert('тут запрещенные слова!')
|
|
|
+ } else {
|
|
|
+ alert('хорошо')
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// confirmA()
|
|
|
+function confirmA() {
|
|
|
+ const result = confirm('A???')
|
|
|
+ console.log(result)
|
|
|
+ console.log(typeof(result))
|
|
|
+}
|
|
|
+
|
|
|
+// ifA()
|
|
|
+function ifA() {
|
|
|
+ const male = confirm('ты мужчина?')
|
|
|
+ const female = confirm('ты женщина?')
|
|
|
+
|
|
|
+ if (male && !female) {
|
|
|
+ alert("ты мужчина")
|
|
|
+ } else if (!male && female) {
|
|
|
+ alert("ты женщина")
|
|
|
+ } else {
|
|
|
+ alert("ты кто??")
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// realArr()
|
|
|
+function realArr() {
|
|
|
+ const alkaliMetals = ['li', 'na', 'k', 'rb', 'cs', 'fr']
|
|
|
+ console.log(alkaliMetals)
|
|
|
+}
|
|
|
+
|
|
|
+// booleans()
|
|
|
+function booleans() {
|
|
|
+ let gender = []
|
|
|
+ let [male, female] = gender
|
|
|
+ male = confirm('ты мужчина?')
|
|
|
+ female = confirm('ты женщина?')
|
|
|
+
|
|
|
+ if (male && !female) {
|
|
|
+ alert("ты мужчина")
|
|
|
+ } else if (!male && female) {
|
|
|
+ alert("ты женщина")
|
|
|
+ } else {
|
|
|
+ alert("ты кто??")
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// plus()
|
|
|
+function plus() {
|
|
|
+ let arr = [10, 15]
|
|
|
+ arr[2] = arr[0] + arr[1]
|
|
|
+ console.log(arr)
|
|
|
+}
|
|
|
+
|
|
|
+// plusString()
|
|
|
+function plusString() {
|
|
|
+ let arr = ['a', 'b', 'c']
|
|
|
+ arr[3] = arr[0] + arr[1] + arr[2]
|
|
|
+ console.log(arr)
|
|
|
+ // можно разбивать строки на символы и хранить в подобном массиве
|
|
|
+}
|
|
|
+
|
|
|
+// realObj()
|
|
|
+function realObj() {
|
|
|
+ let computer = {
|
|
|
+ motherboard: {
|
|
|
+ name: 'Gigabyte B560M DS3H AC s-1200 B560',
|
|
|
+ formFactor: 'micro-ATX',
|
|
|
+ chipset: 'B560M DS3H',
|
|
|
+ socket: 's-1200',
|
|
|
+ },
|
|
|
+ cpu: 'Intel Core i5-10400F',
|
|
|
+ ram: {
|
|
|
+ name: 'Team Vulcan Z Gray',
|
|
|
+ type: 'DDR4',
|
|
|
+ frequency: 2666,
|
|
|
+ size: '8gb*2',
|
|
|
+ },
|
|
|
+ gpu: 'NVIDIA GeForce RTX 3060',
|
|
|
+ storage: {
|
|
|
+ name: 'Kingston DC450R',
|
|
|
+ type: 'SSD',
|
|
|
+ size: '960gb',
|
|
|
+ },
|
|
|
+ cooling: 'QB-OL2000GT',
|
|
|
+ case: 'QUBE FALCON ARGB',
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// changeObj()
|
|
|
+function changeObj() {
|
|
|
+ let computer = {
|
|
|
+ motherboard: {
|
|
|
+ name: 'Gigabyte B560M DS3H AC s-1200 B560',
|
|
|
+ formFactor: 'micro-ATX',
|
|
|
+ chipset: 'B560M DS3H',
|
|
|
+ socket: 's-1200',
|
|
|
+ },
|
|
|
+ cpu: 'Intel Core i5-10400F',
|
|
|
+ ram: {
|
|
|
+ name: 'Team Vulcan Z Gray',
|
|
|
+ type: 'DDR4',
|
|
|
+ frequency: 2666,
|
|
|
+ size: '8gb*2',
|
|
|
+ },
|
|
|
+ gpu: 'NVIDIA GeForce RTX 3060',
|
|
|
+ storage: {
|
|
|
+ name: 'Kingston DC450R',
|
|
|
+ type: 'SSD',
|
|
|
+ size: '960gb',
|
|
|
+ },
|
|
|
+ cooling: 'QB-OL2000GT',
|
|
|
+ case: 'QUBE FALCON ARGB',
|
|
|
+ }
|
|
|
+ computer.gpu = 'NVIDIA GeForce GTX 1060Ti'
|
|
|
+ computer.storage['size'] = '260gb'
|
|
|
+ computer['storage']['name'] = 'Silicon Power'
|
|
|
+ console.log(computer)
|
|
|
+}
|
|
|
+
|
|
|
+// comparisonIf()
|
|
|
+function comparisonIf() {
|
|
|
+ var age = +prompt("Сколько вам лет?","");
|
|
|
+
|
|
|
+ if (age >= 0) {
|
|
|
+ if (age < 18){
|
|
|
+ alert("школьник");
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ if (age < 30){
|
|
|
+ alert("молодеж");
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ if (age < 45){
|
|
|
+ alert("зрелость");
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ if (age < 60){
|
|
|
+ alert("закат");
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ if (age >= 60){
|
|
|
+ alert("как пенсия?");
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ alert("то ли киборг, то ли ошибка");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ alert("родись сначала!");
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// comparisonSizes()
|
|
|
+function comparisonSizes() {
|
|
|
+ let size = +prompt("Введите размер верхней одежды","");
|
|
|
+
|
|
|
+ if (size >= 40) {
|
|
|
+ if (size < 42) {
|
|
|
+ alert("S");
|
|
|
+ } else if (size < 46) {
|
|
|
+ alert("M");
|
|
|
+ } else if (size < 50) {
|
|
|
+ alert("L");
|
|
|
+ } else if (size < 54) {
|
|
|
+ alert("XL");
|
|
|
+ } else if (size === 54) {
|
|
|
+ alert("XXL");
|
|
|
+ } else {
|
|
|
+ alert("слишком много");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ alert("слишком мало");
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+// comparisonObject()
|
|
|
+function comparisonObject() {
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+// ternary()
|
|
|
+function ternary() {
|
|
|
+ let gender = []
|
|
|
+ let [male, female] = gender
|
|
|
+ male = confirm('ты мужчина?')
|
|
|
+ female = confirm('ты женщина?')
|
|
|
+
|
|
|
+ let answer = (male && !female) ? "ты мужчина" : (!male && female) ? "ты женщина" : "ты кто??"
|
|
|
+ alert(answer)
|
|
|
+}
|
|
|
+
|
|
|
+// flats()
|
|
|
+function flats() {
|
|
|
+ const stages = +prompt("Количество этажей","");
|
|
|
+ const flats = +prompt("Количество квартир","");
|
|
|
+ const numder = +prompt("Квартира","");
|
|
|
+
|
|
|
+ const stage = Math.ceil((numder % (stages * flats)) / 4)
|
|
|
+ const entrance = Math.ceil(numder / (stages * flats))
|
|
|
+
|
|
|
+ alert(`${stage} этаж`)
|
|
|
+ alert(`${entrance} подъезд`)
|
|
|
+}
|