123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301 |
- // switch:sizes------------------------------------------------------------------------------------;
- // let sizeOfDressUA = +prompt(
- // "Lets choose the right size for you. Enter your Ukrainian clothing size",
- // []
- // );
- // switch (sizeOfDressUA) {
- // case 38:
- // alert("Your international size is XXS");
- // break;
- // case 40:
- // alert("Your international size is XS");
- // break;
- // case 42:
- // alert("Your international size is S");
- // break;
- // case 44:
- // alert("Your international size is M");
- // break;
- // case 46:
- // alert("Your international size is L");
- // break;
- // case 48:
- // alert("Your international size is XL");
- // break;
- // case 50:
- // alert("Your international size is XXL");
- // break;
- // case 52:
- // alert("Your international size is 3XL");
- // break;
- // default:
- // alert("We do not know size of your dress");
- // }
- // switch:if-------------------------------------------------------------------------------------------;
- // let color = prompt("Enter color", "");
- // if (color === "red") {
- // document.write("<div style='background-color: red;'>Red</div>");
- // } else if (color === "black") {
- // document.write(
- // "<div style='background-color: black; color: white;'>Black</div>"
- // );
- // } else if (color === "blue") {
- // document.write("<div style='background-color: blue;'>Blue</div>");
- // } else if (color === "green") {
- // document.write("<div style='background-color: green;'>Green</div>");
- // } else {
- // document.write(
- // "<div style='background-color: gray;'>I don`t understand</div>"
- // );
- // }
- // prompt: or--------------------------------------------------------------------------------------------;
- // let yearOfBirth =
- // +prompt("Please, type year of your birth", []) ||
- // alert("You did not enter the date of Birth");
- // let currentYear = 2022;
- // let age = currentYear - yearOfBirth;
- // alert(age);
- // confirm: or this days----------------------------------------------------------------------------------;
- // confirm("Shopping?") || alert("You are crazy");
- // confirm: if this days-----------------------------------------------------------------------------------;
- // let answer = confirm("Shopping?");
- // if (answer === false) {
- // alert("You are crazy");
- // } else {
- // alert("Yoohooo");
- // }
- // triple prompt-------------------------------------------------------------------------------------------;
- // let name = prompt("Enter your name", []);
- // let surname = prompt("Enter your surname", []);
- // let patronymic = prompt("Enter your patronymic", []);
- // alert(`${surname}, ${name}, ${patronymic}`);
- // default: or-------------------------------------------------------------------------------------------;
- // let good_name = prompt("Enter your name", []) || "Ivan";
- // let good_surname = prompt("Enter your surname", []) || "Ivanov";
- // let good_patronymic = prompt("Enter your patronymic", []) || "Petrovych";
- // alert(`${good_surname}, ${good_name}, ${good_patronymic}`);
- // default: if-------------------------------------------------------------------------------------------;
- // let go_name = prompt("Enter your name", []);
- // let go_surname = prompt("Enter your surname", []);
- // let go_patronymic = prompt("Enter your patronymic", []);
- // if (go_name === null) {
- // go_name = "Ivan";
- // } else if (go_surname === null) {
- // go_surname = "Ivanov";
- // } else if (go_patronymic === null) {
- // go_surname = "Petrovych";
- // }
- // alert(`${go_surname}, ${go_name}, ${go_patronymic}`);
- // login and password-------------------------------------------------------------------------------------------;
- // let user_login = prompt("Enter your login");
- // let user_password = prompt("Enter your password");
- // if (user_login != "admin" || user_password != "qwerty") {
- // alert("Access denied");
- // } else if (user_login === "admin" && user_password === "qwerty") {
- // alert("Access success");
- // }
- // currency calc-------------------------------------------------------------------------------------------;
- // let money = prompt("usd or eur?", []);
- // switch (money) {
- // case "usd":
- // let currensy_exchange = 0.027;
- // let uah = prompt("Enter the amount in hryvnias");
- // let amount = uah * currensy_exchange;
- // alert(amount);
- // break;
- // case "eur":
- // let ecurrensy_exchange = 0.025;
- // let u_ah = prompt("Enter the amount in hryvnias");
- // let amo_unt = u_ah * ecurrensy_exchange;
- // alert(amo_unt);
- // break;
- // }
- // currency calc: improved-------------------------------------------------------------------------------------------;
- // let money = prompt("usd or eur?", []);
- // money = money.toLowerCase();
- // switch (money) {
- // case "usd":
- // let currensy_exchange = 38.4;
- // let uah = prompt("Enter the amount in hryvnias");
- // let amount = uah / currensy_exchange;
- // alert(amount);
- // break;
- // case "eur":
- // let ecurrensy_exchange = 39;
- // let u_ah = prompt("Enter the amount in hryvnias");
- // let amo_unt = u_ah / ecurrensy_exchange;
- // alert(amo_unt);
- // break;
- // }
- // currency calc: two rates-------------------------------------------------------------------------------------------;
- // let money = prompt("usd or eur?", []);
- // money = money.toLowerCase();
- // let buyOrSale = confirm("You want buy currensy?", []);
- // switch (money) {
- // case "usd":
- // let currensy_exchange = buyOrSale === true ? 39.8 : 38.4;
- // let uah = prompt("Enter the amount in hryvnias");
- // let amount = uah / currensy_exchange;
- // alert(amount);
- // break;
- // case "eur":
- // let ecurrensy_exchange = buyOrSale === true ? 40.4 : 39;
- // let u_ah = prompt("Enter the amount in hryvnias");
- // let amo_unt = u_ah / ecurrensy_exchange;
- // alert(amo_unt);
- // break;
- // }
- // currency calc: if-------------------------------------------------------------------------------------------;
- // let money = prompt("usd or eur?", []);
- // money = money.toLowerCase();
- // let buyOrSale = confirm("You want buy currensy?", []);
- // if (money === "usd") {
- // let currensy_exchange = buyOrSale === true ? 39.8 : 38.4;
- // let uah = prompt("Enter the amount in hryvnias");
- // let amount = uah / currensy_exchange;
- // alert(amount);
- // } else if (money === "eur") {
- // let ecurrensy_exchange = buyOrSale === true ? 40.4 : 39;
- // let u_ah = prompt("Enter the amount in hryvnias");
- // let amo_unt = u_ah / ecurrensy_exchange;
- // alert(amo_unt);
- // } else {
- // alert("Enter a valid currensy");
- // }
- // scissors-------------------------------------------------------------------------------------------;
- // let select = prompt("paper , scissors, stone");
- // let items = ["paper", "scissors", "stone"];
- // select = select.toLowerCase();
- // alert(`You choose a ${select}`);
- // select = select.toLowerCase();
- // let selectComputer = items[Math.floor(Math.random() * items.length)];
- // alert(`Robot choose a ${selectComputer}`);
- // if (select === selectComputer) {
- // alert("draw");
- // } else if (select === "stone") {
- // if (selectComputer === "scissors") {
- // alert("You are win");
- // } else {
- // alert("You are lose");
- // }
- // } else if (select === "paper") {
- // if (selectComputer === "stone") {
- // alert("You are win");
- // } else {
- // alert("You are lose");
- // }
- // }
- // if (select === "scissors") {
- // if (selectComputer === "stone") {
- // alert("You are lose");
- // } else {
- // alert("You are win");
- // }
- // } else "Renew game";
- // Задание на синий пояс-------------------------------------------------------------------------------------------;
- // let usd = {
- // buyUsd: 38.4,
- // saleUsd: 39.8,
- // };
- // let eur = {
- // buyEur: 39,
- // saleEur: 40.4,
- // };
- // let gbp = {
- // buyGbp: 46,
- // saleGbp: 48.5,
- // };
- // let money = prompt("usd, eur or gbp?", []);
- // money = money.toLowerCase();
- // let buyOrSale = confirm("You want to buy currensy?", []);
- // if (money === "usd") {
- // currency_exchange = buyOrSale === true ? usd.saleUsd : usd.buyUsd;
- // } else if (money === "eur") {
- // currency_exchange = buyOrSale === true ? eur.saleEur : eur.buyEur;
- // } else if (money === "eur") {
- // currency_exchange = buyOrSale === true ? gbp.saleGbp : gbp.buyGbp;
- // } else {
- // alert("We do noy know such a currency");
- // }
- // let hryvnias = prompt("How much hryvnias do you want to exchange?");
- // let amount = hryvnias / currency_exchange;
- // alert(`You will get ${amount} ${money}`);
- // real data-------------------------------------------------------------------------------------------;
- let user_choice = prompt("How many hryvnias you want exchange?", []);
- let rates = prompt("You want to buy usd, eur or gbp?", []);
- rates = rates.toUpperCase();
- getCurrencies();
- async function getCurrencies() {
- const response = await fetch("https://open.er-api.com/v6/latest/UAH");
- const data = await response.json();
- if (rates === "USD") {
- amount = data.rates.USD * user_choice;
- alert(`You will get ${amount} ${rates}`);
- } else if (rates === "EUR") {
- amount = data.rates.EUR * user_choice;
- alert(`You will get ${amount} ${rates}`);
- } else if (rates === "GBP") {
- amount = data.rates.GBP * user_choice;
- alert(`You will get ${amount} ${rates}`);
- } else {
- alert("We don`t know such currency");
- }
- }
- // Дополнительное задание-------------------------------------------------------------------------------------------;
- // Задание на черный пояс-------------------------------------------------------------------------------------------;
|