Browse Source

HW<3> done

Andrey 1 year ago
parent
commit
238b459d8e
1 changed files with 26 additions and 15 deletions
  1. 26 15
      Dz3 js/Dz3js.html

+ 26 - 15
Dz3 js/Dz3js.html

@@ -68,25 +68,24 @@
 
 
                 }
+                break;
 
             case "switch: if":
                 let color = prompt("Введите цвет", "");
-                if (color == "red") {
+                if ((color == "red") || (color == "black")) {
                     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") {
+
+                else if ((color == "blue") || (color == "green")) {
                     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>")
                 }
+                break;
 
             case "Number: age":
                 let year = 2022;
@@ -101,12 +100,14 @@
                 } else {
                     alert("NO_NO!")
                 }
+                break;
 
 
 
             case "confirm: or this days":
                 let shopping = confirm("Шопинг?")
                 alert(shopping || "Ты бяка!")
+                break;
 
             case "confirm: if this days":
                 let shopping2 = confirm("Шопинг?")
@@ -115,6 +116,7 @@
                 } else if ((shopping2 == null) || (shopping2 == "")) {
                     alert("Ты бяка!")
                 }
+                break;
 
 
 
@@ -125,6 +127,7 @@
                 let userPatronymic = prompt("Введите ваше отчество:")
                 let fullName = userSurname + ' ' + userName + ' ' + userPatronymic;
                 alert(fullName)
+                break;
 
             case "default: or":
                 let userSurname2 = prompt("Введите вашу фамилию:") || ("Иванов")
@@ -132,6 +135,7 @@
                 let userPatronymic2 = prompt("Введите ваше отчество:") || ("Иваночив")
                 let fullName2 = userSurname2 + ' ' + userName2 + ' ' + userPatronymic2;
                 alert(fullName)
+                break;
 
             case "default: if":
 
@@ -149,6 +153,7 @@
                 }
 
                 alert(userSurname3 + " " + userName3 + " " + userPatronymic3);
+                break;
 
 
 
@@ -168,6 +173,7 @@
                 } else {
                     alert("Вы кто такой? Я вас не звал! Идите за русским кораблем!")
                 }
+                break;
 
             case "currency calc":
                 // case "currency calc: improved":
@@ -192,6 +198,7 @@
 
 
                 }
+                break;
             case "currency calc: if":
                 let currency2 = prompt("Выбирете валюту: usd или eur ").toLowerCase();
                 let UAH2 = prompt("Введите сумму в гривнах: ");
@@ -210,6 +217,7 @@
                 else {
                     alert("Простите мы закрыты!")
                 }
+                break;
 
             case "scissors":
                 let userChoice = Number(prompt("Выбирите число от 1 до 3. 1 - камень 2 - ножницы, 3 - бумага"))
@@ -217,12 +225,13 @@
                 alert(`Противник выбрал: ${compRandom} `)
                 if (userChoice === 1 && compRandom === 2 || userChoice === 2 && compRandom === 3 || userChoice === 3 && compRandom === 1) {
                     alert("Ура!!!Вы победили!")
+                } else if (userChoice === 1 && compRandom === 1 || userChoice === 2 && compRandom === 2 || userChoice === 3 && compRandom === 3) {
+                    alert("Победила дружба!!!")
                 }
-                else if (userChoice === 3 && compRandom === 2 || userChoice === 2 && compRandom === 1 || userChoice === 1 && compRandom === 3) {
+                else {
                     alert("ОЙ-ОЙ!Вы проиграли!")
-                } else {
-                    alert("Победила дружба!!!")
                 }
+                break;
 
             case "Задание на синий пояс":
                 let currencySelection = prompt("Выбери одну валюту на выбор: usd или eur").toLowerCase();
@@ -238,25 +247,27 @@
                 } else {
                     alert("Вы ввели не верные данные!")
                 }
+                break;
 
             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)
+                    fetch('https://open.er-api.com/v6/latest/USD').then((res) => res.json())
+                        .then((data) => {
+                            alert(enterAmount2 / 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)
+                    fetch('https://open.er-api.com/v6/latest/EUR').then((res) => res.json())
+                        .then((data) => {
+                            alert(enterAmount2 / data.rates.UAH)
                         })
                 }
                 else {
                     alert("Что-то пошло не так!")
                 }
+                break;
         }