|
@@ -10,8 +10,8 @@
|
|
|
|
|
|
<body>
|
|
|
<script>
|
|
|
- let taskName = prompt ("Введите название задания:")
|
|
|
- switch(taskName){
|
|
|
+ let taskName = prompt("Введите название задания:")
|
|
|
+ switch (taskName) {
|
|
|
case "switch: sizes":
|
|
|
let country = prompt("Выбирете страну на выбор: Италия, Швейцария")
|
|
|
let size = prompt("Введите размер верхней одежды: от 46 - до 50.")
|
|
@@ -68,218 +68,196 @@
|
|
|
|
|
|
|
|
|
}
|
|
|
-
|
|
|
- case "switch: if":
|
|
|
- let color = prompt("Введите цвет", "");
|
|
|
- if (color == "red") {
|
|
|
- document.write("<div style='background-color: red;'>красный</div>")
|
|
|
- }
|
|
|
- else if (color == "black") {
|
|
|
- document.write("<div style='background-color: black; color: white;'>черный</div>");
|
|
|
- }
|
|
|
- else if (color == "blue") {
|
|
|
- document.write("<div style='background-color: blue;'>синий</div>");
|
|
|
- }
|
|
|
- else if (color == "green") {
|
|
|
- document.write("<div style='background-color: green;'>зеленый</div>");
|
|
|
- }
|
|
|
-
|
|
|
- else {
|
|
|
- document.write("<div style='background-color: gray;'>Я не понял</div>")
|
|
|
- }
|
|
|
-
|
|
|
- case "Number: age":
|
|
|
- let year = 2022;
|
|
|
- let birthday;
|
|
|
- let age = +prompt("Сколько вам лет?")
|
|
|
- if (age) {
|
|
|
- birthday = year - age;
|
|
|
- alert(birthday + " г.р.");
|
|
|
- }
|
|
|
- else if ((age == null) || (age == "")) {
|
|
|
- alert("Ошибка!")
|
|
|
- }else {
|
|
|
- alert("NO_NO!")
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- case "confirm: or this days":
|
|
|
- let shopping = confirm("Шопинг?")
|
|
|
- alert(shopping || "Ты бяка!")
|
|
|
-
|
|
|
- case "confirm: if this days":
|
|
|
- let shopping2 = confirm("Шопинг?")
|
|
|
- if (shopping2) {
|
|
|
- alert("Люблю покупки!")
|
|
|
- }else if((shopping2 == null) || (shopping2 == "")){
|
|
|
- alert("Ты бяка!")
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- case "triple prompt":
|
|
|
- let userSurname = prompt("Введите вашу фамилию:")
|
|
|
- let userName = prompt("Введите ваше имя:")
|
|
|
- let userPatronymic = prompt("Введите ваше отчество:")
|
|
|
- let fullName = userSurname + ' ' + userName + ' ' + userPatronymic;
|
|
|
- alert(fullName)
|
|
|
-
|
|
|
- case "default: or":
|
|
|
- let userSurname2 = prompt("Введите вашу фамилию:") || ("Иванов" )
|
|
|
- let userName2 = prompt("Введите ваше имя:") || ("Иван")
|
|
|
- let userPatronymic2 = prompt("Введите ваше отчество:") || ("Иваночив")
|
|
|
- let fullName2 = userSurname2 + ' ' + userName2 + ' ' + userPatronymic2;
|
|
|
- alert(fullName)
|
|
|
-
|
|
|
- case "default: if":
|
|
|
-
|
|
|
- let userName3 = prompt("Введите ваше имя");
|
|
|
- let userSurname3 = prompt("Введите вашу фамилию");
|
|
|
- let userPatronymic3 = prompt("Введите ваше отчество");
|
|
|
- if (userName3 == null || "") {
|
|
|
- userName3 = "Иван";
|
|
|
- }
|
|
|
- if (userSurname3 == null || "") {
|
|
|
- userSurname3 = "Иванов";
|
|
|
- }
|
|
|
- if (userPatronymic3 == null || "") {
|
|
|
- userPatronymic3 = "Иванович";
|
|
|
- }
|
|
|
-
|
|
|
- alert(userSurname3 + " " + userName3 + " " + userPatronymic3);
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- case "login and password":
|
|
|
- let login = prompt("Введите ваш логин:");
|
|
|
- if(login === "admin"){
|
|
|
- let password = prompt("Введите ваш пароль:");
|
|
|
- if (password === "qwerty"){
|
|
|
- alert("Поздравляю!");
|
|
|
- }else if(password === "" || password === null) {
|
|
|
- alert("Охрана-Отмена!");
|
|
|
- }else {
|
|
|
- alert("Неверный пароль!!!")
|
|
|
- }
|
|
|
- }else if (login === "" || login === null){
|
|
|
- alert("Не тут то было!")
|
|
|
- }else{
|
|
|
- alert("Вы кто такой? Я вас не звал! Идите за русским кораблем!")
|
|
|
- }
|
|
|
-
|
|
|
- case "currency calc":
|
|
|
- // case "currency calc: improved":
|
|
|
- // //case "currency calc: two rates":
|
|
|
- let currency = prompt("Выбирете валюту: usd или eur ").toLowerCase();
|
|
|
- let UAH = prompt("Введите сумму в гривнах: ");
|
|
|
- let usdPurchase = 29.2;
|
|
|
- let usdSale = 29.5;
|
|
|
- let eurPurchase = 31.4;
|
|
|
- let eurSale = 32.2;
|
|
|
- switch (currency) {
|
|
|
-
|
|
|
- case "usd": let userExchangeUsd = confirm("Выберите покупка или проадажа? ок-покупка отмена-продажа") ? (UAH / usdPurchase) : (UAH / usdSale)
|
|
|
- alert(userExchangeUsd)
|
|
|
- break;
|
|
|
-
|
|
|
- case "eur": let userExchangeEur = confirm("Выберите покупка или проадажа? ок-покупка отмена-продажа") ? (UAH / eurPurchase) : (UAH / eurSale)
|
|
|
- alert(userExchangeEur)
|
|
|
- break;
|
|
|
-
|
|
|
- default: alert("Простите мы закрыты!")
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
- case "currency calc: if":
|
|
|
- let currency = prompt("Выбирете валюту: usd или eur ").toLowerCase();
|
|
|
- let UAH = prompt("Введите сумму в гривнах: ");
|
|
|
- let usdPurchase = 29.2;
|
|
|
- let usdSale = 29.5;
|
|
|
- let eurPurchase = 31.4;
|
|
|
- let eurSale = 32.2;
|
|
|
- if (currency === "usd") {
|
|
|
- let userExchangeUsd = confirm("Выберите покупка или проадажа? ок-покупка отмена-продажа") ? (UAH / usdPurchase) : (UAH / usdSale)
|
|
|
- alert(userExchangeUsd)
|
|
|
- }
|
|
|
- else if (currency === "eur") {
|
|
|
- let userExchangeEur = confirm("Выберите покупка или проадажа? ок-покупка отмена-продажа") ? (UAH / eurPurchase) : (UAH / eurSale)
|
|
|
- alert(userExchangeEur)
|
|
|
- }
|
|
|
- else {
|
|
|
- alert("Простите мы закрыты!")
|
|
|
- }
|
|
|
-
|
|
|
- case "scissors":
|
|
|
- let userChoice = Number(prompt("Выбирите число от 1 до 3. 1 - камень 2 - ножницы, 3 - бумага"))
|
|
|
- let compRandom = Math.ceil(Math.random() * 3)
|
|
|
- alert(`Противник выбрал: ${compRandom} `)
|
|
|
- if (userChoice === 1 && compRandom === 2 || userChoice === 2 && compRandom === 3 || userChoice === 3 && compRandom === 1) {
|
|
|
- alert("Ура!!!Вы победили!")
|
|
|
- }
|
|
|
- else if (userChoice === 3 && compRandom === 2 || userChoice=== 2 && compRandom === 1 || userChoice === 1 && compRandom === 3) {
|
|
|
- alert("ОЙ-ОЙ!Вы проиграли!")
|
|
|
- } else {
|
|
|
- alert("Победила дружба!!!")
|
|
|
- }
|
|
|
-
|
|
|
- case "Задание на синий пояс":
|
|
|
- let currencySelection = prompt("Выбери одну валюту на выбор: usd или eur").toLowerCase();
|
|
|
- let enterAmount = prompt ("Введите сумму в гривнах")
|
|
|
- let ratios = {
|
|
|
- usd: 25.6,
|
|
|
- eur: 29
|
|
|
- }
|
|
|
- if (currencySelection === "usd"){
|
|
|
- alert(enterAmount / ratios["usd"])
|
|
|
- } else if (currencySelection === "eur"){
|
|
|
- alert(enterAmount / ratios["eur"])
|
|
|
- }else {
|
|
|
- alert("Вы ввели не верные данные!")
|
|
|
- }
|
|
|
-
|
|
|
- case "real data":
|
|
|
- let currencySelection2 = prompt("Выбери одну валюту на выбор: usd или eur").toLowerCase();
|
|
|
- let enterAmount2 = prompt ("Введите сумму в гривнах");
|
|
|
- if(currencySelection2 === "usd"){
|
|
|
- fetch('https://open.er-api.com/v6/latest/USD').then(res => res.json())
|
|
|
- .then(data => {
|
|
|
- alert(data.rates.UAH)
|
|
|
- })}
|
|
|
- else if (currencySelection2 === "eur"){
|
|
|
- fetch('https://open.er-api.com/v6/latest/EUR').then(res => res.json())
|
|
|
- .then(data => {
|
|
|
- alert(data.rates.UAH)
|
|
|
- })}
|
|
|
- else {
|
|
|
- alert("Что-то пошло не так!")
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
|
|
|
+ case "switch: if":
|
|
|
+ let color = prompt("Введите цвет", "");
|
|
|
+ if (color == "red") {
|
|
|
+ document.write("<div style='background-color: red;'>красный</div>")
|
|
|
+ }
|
|
|
+ else if (color == "black") {
|
|
|
+ document.write("<div style='background-color: black; color: white;'>черный</div>");
|
|
|
+ }
|
|
|
+ else if (color == "blue") {
|
|
|
+ document.write("<div style='background-color: blue;'>синий</div>");
|
|
|
+ }
|
|
|
+ else if (color == "green") {
|
|
|
+ document.write("<div style='background-color: green;'>зеленый</div>");
|
|
|
+ }
|
|
|
|
|
|
+ else {
|
|
|
+ document.write("<div style='background-color: gray;'>Я не понял</div>")
|
|
|
+ }
|
|
|
|
|
|
+ case "Number: age":
|
|
|
+ let year = 2022;
|
|
|
+ let birthday;
|
|
|
+ let age = +prompt("Сколько вам лет?")
|
|
|
+ if (age) {
|
|
|
+ birthday = year - age;
|
|
|
+ alert(birthday + " г.р.");
|
|
|
+ }
|
|
|
+ else if ((age == null) || (age == "")) {
|
|
|
+ alert("Ошибка!")
|
|
|
+ } else {
|
|
|
+ alert("NO_NO!")
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
|
|
+ case "confirm: or this days":
|
|
|
+ let shopping = confirm("Шопинг?")
|
|
|
+ alert(shopping || "Ты бяка!")
|
|
|
|
|
|
+ case "confirm: if this days":
|
|
|
+ let shopping2 = confirm("Шопинг?")
|
|
|
+ if (shopping2) {
|
|
|
+ alert("Люблю покупки!")
|
|
|
+ } else if ((shopping2 == null) || (shopping2 == "")) {
|
|
|
+ alert("Ты бяка!")
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+ case "triple prompt":
|
|
|
+ let userSurname = prompt("Введите вашу фамилию:")
|
|
|
+ let userName = prompt("Введите ваше имя:")
|
|
|
+ let userPatronymic = prompt("Введите ваше отчество:")
|
|
|
+ let fullName = userSurname + ' ' + userName + ' ' + userPatronymic;
|
|
|
+ alert(fullName)
|
|
|
|
|
|
+ case "default: or":
|
|
|
+ let userSurname2 = prompt("Введите вашу фамилию:") || ("Иванов")
|
|
|
+ let userName2 = prompt("Введите ваше имя:") || ("Иван")
|
|
|
+ let userPatronymic2 = prompt("Введите ваше отчество:") || ("Иваночив")
|
|
|
+ let fullName2 = userSurname2 + ' ' + userName2 + ' ' + userPatronymic2;
|
|
|
+ alert(fullName)
|
|
|
|
|
|
+ case "default: if":
|
|
|
|
|
|
+ let userName3 = prompt("Введите ваше имя");
|
|
|
+ let userSurname3 = prompt("Введите вашу фамилию");
|
|
|
+ let userPatronymic3 = prompt("Введите ваше отчество");
|
|
|
+ if (userName3 == null || "") {
|
|
|
+ userName3 = "Иван";
|
|
|
+ }
|
|
|
+ if (userSurname3 == null || "") {
|
|
|
+ userSurname3 = "Иванов";
|
|
|
+ }
|
|
|
+ if (userPatronymic3 == null || "") {
|
|
|
+ userPatronymic3 = "Иванович";
|
|
|
+ }
|
|
|
|
|
|
+ alert(userSurname3 + " " + userName3 + " " + userPatronymic3);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ case "login and password":
|
|
|
+ let login = prompt("Введите ваш логин:");
|
|
|
+ if (login === "admin") {
|
|
|
+ let password = prompt("Введите ваш пароль:");
|
|
|
+ if (password === "qwerty") {
|
|
|
+ alert("Поздравляю!");
|
|
|
+ } else if (password === "" || password === null) {
|
|
|
+ alert("Охрана-Отмена!");
|
|
|
+ } else {
|
|
|
+ alert("Неверный пароль!!!")
|
|
|
+ }
|
|
|
+ } else if (login === "" || login === null) {
|
|
|
+ alert("Не тут то было!")
|
|
|
+ } else {
|
|
|
+ alert("Вы кто такой? Я вас не звал! Идите за русским кораблем!")
|
|
|
+ }
|
|
|
|
|
|
+ case "currency calc":
|
|
|
+ // case "currency calc: improved":
|
|
|
+ // //case "currency calc: two rates":
|
|
|
+ let currency = prompt("Выбирете валюту: usd или eur ").toLowerCase();
|
|
|
+ let UAH = prompt("Введите сумму в гривнах: ");
|
|
|
+ let usdPurchase = 29.2;
|
|
|
+ let usdSale = 29.5;
|
|
|
+ let eurPurchase = 31.4;
|
|
|
+ let eurSale = 32.2;
|
|
|
+ switch (currency) {
|
|
|
+
|
|
|
+ case "usd": let userExchangeUsd = confirm("Выберите покупка или проадажа? ок-покупка отмена-продажа") ? (UAH / usdPurchase) : (UAH / usdSale)
|
|
|
+ alert(userExchangeUsd)
|
|
|
+ break;
|
|
|
|
|
|
+ case "eur": let userExchangeEur = confirm("Выберите покупка или проадажа? ок-покупка отмена-продажа") ? (UAH / eurPurchase) : (UAH / eurSale)
|
|
|
+ alert(userExchangeEur)
|
|
|
+ break;
|
|
|
|
|
|
+ default: alert("Простите мы закрыты!")
|
|
|
|
|
|
|
|
|
+ }
|
|
|
+ case "currency calc: if":
|
|
|
+ let currency2 = prompt("Выбирете валюту: usd или eur ").toLowerCase();
|
|
|
+ let UAH2 = prompt("Введите сумму в гривнах: ");
|
|
|
+ let usdPurchase2 = 29.2;
|
|
|
+ let usdSale2 = 29.5;
|
|
|
+ let eurPurchase2 = 31.4;
|
|
|
+ let eurSale2 = 32.2;
|
|
|
+ if (currency2 === "usd") {
|
|
|
+ let userExchangeUsd2 = confirm("Выберите покупка или проадажа? ок-покупка отмена-продажа") ? (UAH2 / usdPurchase2) : (UAH2 / usdSale2)
|
|
|
+ alert(userExchangeUsd2)
|
|
|
+ }
|
|
|
+ else if (currency2 === "eur") {
|
|
|
+ let userExchangeEur2 = confirm("Выберите покупка или проадажа? ок-покупка отмена-продажа") ? (UAH2 / eurPurchase2) : (UAH2 / eurSale2)
|
|
|
+ alert(userExchangeEur2)
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ alert("Простите мы закрыты!")
|
|
|
+ }
|
|
|
|
|
|
+ case "scissors":
|
|
|
+ let userChoice = Number(prompt("Выбирите число от 1 до 3. 1 - камень 2 - ножницы, 3 - бумага"))
|
|
|
+ let compRandom = Math.ceil(Math.random() * 3)
|
|
|
+ alert(`Противник выбрал: ${compRandom} `)
|
|
|
+ if (userChoice === 1 && compRandom === 2 || userChoice === 2 && compRandom === 3 || userChoice === 3 && compRandom === 1) {
|
|
|
+ alert("Ура!!!Вы победили!")
|
|
|
+ }
|
|
|
+ else if (userChoice === 3 && compRandom === 2 || userChoice === 2 && compRandom === 1 || userChoice === 1 && compRandom === 3) {
|
|
|
+ alert("ОЙ-ОЙ!Вы проиграли!")
|
|
|
+ } else {
|
|
|
+ alert("Победила дружба!!!")
|
|
|
+ }
|
|
|
|
|
|
+ case "Задание на синий пояс":
|
|
|
+ let currencySelection = prompt("Выбери одну валюту на выбор: usd или eur").toLowerCase();
|
|
|
+ let enterAmount = prompt("Введите сумму в гривнах")
|
|
|
+ let ratios = {
|
|
|
+ usd: 25.6,
|
|
|
+ eur: 29
|
|
|
+ }
|
|
|
+ if (currencySelection === "usd") {
|
|
|
+ alert(enterAmount / ratios["usd"])
|
|
|
+ } else if (currencySelection === "eur") {
|
|
|
+ alert(enterAmount / ratios["eur"])
|
|
|
+ } else {
|
|
|
+ alert("Вы ввели не верные данные!")
|
|
|
+ }
|
|
|
|
|
|
+ case "real data":
|
|
|
+ let currencySelection2 = prompt("Выбери одну валюту на выбор: usd или eur").toLowerCase();
|
|
|
+ let enterAmount2 = prompt("Введите сумму в гривнах");
|
|
|
+ if (currencySelection2 === "usd") {
|
|
|
+ fetch('https://open.er-api.com/v6/latest/USD').then(res => res.json())
|
|
|
+ .then(data => {
|
|
|
+ alert(data.rates.UAH)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ else if (currencySelection2 === "eur") {
|
|
|
+ fetch('https://open.er-api.com/v6/latest/EUR').then(res => res.json())
|
|
|
+ .then(data => {
|
|
|
+ alert(data.rates.UAH)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ alert("Что-то пошло не так!")
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
|
|
|
</script>
|