// 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("
Red
"); // } else if (color === "black") { // document.write( // "
Black
" // ); // } else if (color === "blue") { // document.write("
Blue
"); // } else if (color === "green") { // document.write("
Green
"); // } else { // document.write( // "
I don`t understand
" // ); // } // 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"); } } // Дополнительное задание-------------------------------------------------------------------------------------------; // Задание на черный пояс-------------------------------------------------------------------------------------------;