This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let goToMetro = +prompt('Сколько минут идти до метро?'); | |
| let stoppingsMetro = +prompt('Сколько остановок ехать в метро?'); | |
| let stoppingsBus = +prompt('Сколько остановок ехать в маршрутке?'); | |
| let totalTimeInMetro = stoppingsMetro * 4; //4 минуты - примерно сколько проезжаю 1 остановку | |
| let totalTimeInBus = stoppingsBus * 2; //2 минуты - примерно сколько проезжаю 1 остановку | |
| let totalTimeRoad = goToMetro + totalTimeInMetro + totalTimeInBus; | |
| alert(`Вся дорога занимает ${totalTimeRoad} минут`); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Синий пояс Number: flats | |
| let xFloat = prompt('Введите квартиру, которую нужно найти'); | |
| let totalFloor = prompt('Сколько всего этажей в доме?'); | |
| let flatOnTheFloor = prompt('Сколько квартир на этаже?'); | |
| let flatInEntrance = totalFloor * flatOnTheFloor; | |
| let entrance = Math.floor((xFloat - 1) / flatInEntrance) + 1; | |
| let floor = Math.floor((xFloat - 1) % flatInEntrance / flatOnTheFloor) + 1; | |
| alert(`Подьезд ${entrance}, этаж ${floor}`); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Ternary | |
| let gender = confirm('Ваш пол женский?'); | |
| let sex = (gender) ? alert('Значит вы женщина') : alert('Значит вы мужчина'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Comparison: object | |
| let lingerie = { | |
| waistСircumference: "63-65", | |
| hipGirth: "89-92", | |
| size: "XXS" | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Comparison: sizes | |
| let sizeUSA = prompt('Введите ваш американский размер одежды'); | |
| if (sizeUSA == 6 || sizeUSA == "S") { | |
| alert('Ваш итальянский размер одежды: 38'); | |
| } else if (sizeUSA == 8 || sizeUSA == "M") { | |
| alert('Ваш итальянский размер одежды: 40'); | |
| } else if (sizeUSA == 12 || sizeUSA == "L") { | |
| alert('Ваш итальянский размер одежды: 42'); | |
| } else if (sizeUSA == 16 || sizeUSA == "XL") { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Comparison if | |
| var age = +prompt("Сколько вам лет?", ""); | |
| if (age < 18) { | |
| alert("школьник"); | |
| } | |
| else if (age >= 18 && age < 30) { | |
| alert("молодежь"); | |
| } | |
| else if (age >= 30 && age < 45) { | |
| alert("зрелость"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Object: real | |
| let hair = { | |
| color: "blond", | |
| hairstyle: "bob", | |
| length: "short" | |
| } | |
| let phone = { | |
| color: "green", | |
| model: "Samsung", | |
| phoneMemory: "512" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Array: real | |
| // Дни недели, список учеников, алфавит | |
| //Array: booleans : plus | |
| let arr = [water, winter, sex]; | |
| arr[2] = arr[0] + arr[1]; | |
| console.log(arr); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Boolean: if | |
| let sex = confirm('Если вы женщина, нажмите ОК'); | |
| if (sex == true) { | |
| alert('Вы женщина'); | |
| } else { | |
| alert('Вы мужчина'); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //confirm | |
| //confirm возвращает булевые значения true или false | |
| //Boolean | |
| let water = confirm('Вода мокрая?'); | |
| console.log(water); | |
| let winter = confirm('Сейчас зима?'); | |
| console.log(winter); |
NewerOlder