// ------------------switch: if ------------------------------------ let color = prompt("Enter text",""); if (color === "red") { document.write("
red
"); document.write("
black
"); } else if (color === "black") { document.write("
black
"); } else if (color === "blue") { document.write("
blue
"); document.write("
green
"); } else if (color === "green") { document.write("
green
"); } else { document.write("
I can't understand
"); } // ------------------confirm: or this days ------------------------------------ let shopping = confirm("шопинг?"); if (shopping === false) { alert("ты - бяка"); } // ------------------triple prompt ------------------------------------ let name = prompt("Enter your name"); let surname = prompt("Enter your surname"); let fathersName = prompt("Enter your fathersName"); alert(`${name} ${surname} ${fathersName}`); // ------------------default: of ------------------------------------ let name = prompt("Enter your name"); if (typeof(name) != String) { name = "Валерий"; } let surname = prompt("Enter your surname"); if (typeof(surname) != String) { surname = "Иванов"; } let fathersName = prompt("Enter your fathersName"); if (typeof(fathersName) != String) { fathersName = "Дмитриевич"; } alert(`${name} ${surname} ${fathersName}`); // ------------------login and password ------------------------------------ let login = prompt('Enter login', 'default'); if (login == 'admin') { let password = prompt('Password', 'Enter password'); if (password == 'qwerty') { alert('Hello Admin'); } else if (password == '' || password == null) { alert('Wrong password'); } else { alert('Cancelled'); } } else if (login == null || login == '') { alert('Cancelled'); } else { alert("Login is wrong"); } // ------------------currency calc ------------------------------------ const dollarUSDtoBuy = 28.25; const dollarUSDforSale = 28.37; const euroEURtoBuy = 33.25; const euroEURforSale = 33.35; let currency = (prompt("Enter currency", "USD or EUR").toUpperCase()); let forChange = +prompt("Enter number HRN for change"); let buyOrSale = confirm("To you want to buy?") switch (currency, buyOrSale) { case "USD" && true: alert(dollarUSDtoBuy * forChange); break; case "USD" && false: alert(dollarUSDforSale * forChange); break; case "EUR" && true: alert(euroEURtoBuy * forChange); break; case "EUR" && false: alert(euroEURforSale * forChange); break; default: alert("Wrong data were entered"); } // ------------------currency calc: if ------------------------------------ const dollarUSDtoBuy = 28.25; const dollarUSDforSale = 28.37; const euroEURtoBuy = 33.25; const euroEURforSale = 33.35; let currency = (prompt("Enter currency", "USD or EUR").toUpperCase()); let forChange = +prompt("Enter number HRN for change"); let buyOrSale = confirm("Do you want to buy?") if (currency === "USD" && buyOrSale === true) { alert(dollarUSDtoBuy * forChange); } else if (currency === "USD" && buyOrSale === false) { alert(dollarUSDforSale * forChange); } else if (currency === "EUR" && buyOrSale === true) { alert(euroEURtoBuy * forChange); } else if (currency === "EUR" && buyOrSale === false) { alert(euroEURforSale * forChange); } else { alert("Wrong data were entered"); } // ------------------scissors ------------------------------------ let userChoise = prompt("Enter your choise", "rock, paper, scissors"); let computerChoise = Math.random(); if (computerChoise <= 0.33) { computerChoise = "rock" alert("rock"); } else if (computerChoise > 0.33 && computerChoise <= 0.66) { computerChoise = "paper" alert("paper"); } else { computerChoise = "scissors" alert("scissors"); } if (userChoise === "rock" && computerChoise === "scissors" ) { alert("User wins"); } else if (userChoise === "rock" && computerChoise === "rock" ) { alert("Nobody wins"); } else if (userChoise === "paper" && computerChoise === "rock" ) { alert("User wins"); } else if (userChoise === "paper" && computerChoise === "paper" ) { alert("Nobody wins"); } else if (userChoise === "scissors" && computerChoise === "paper" ) { alert("User wins"); } else if (userChoise === "scissors" && computerChoise === "scissors" ) { alert("Nobody wins"); } else { alert("Computer wins"); } // ------------------scissors ------------------------------------ let exchangeRates = { dollarUSDtoBuy: 28.25, dollarUSDforSale: 28.37, euroEURtoBuy: 33.25, euroEURforSale: 33.35, } let currency = (prompt("Enter currency", "USD or EUR").toUpperCase()); let forChange = +prompt("Enter number HRN for change"); let buyOrSale = confirm("Do you want to buy?") if (currency === "USD" && buyOrSale === true) { alert(exchangeRates.dollarUSDtoBuy * forChange); } else if (currency === "USD" && buyOrSale === false) { alert(exchangeRates.dollarUSDforSale * forChange); } else if (currency === "EUR" && buyOrSale === true) { alert(exchangeRates.euroEURtoBuy * forChange); } else if (currency === "EUR" && buyOrSale === false) { alert(exchangeRates.euroEURforSale * forChange); } else { alert("Wrong data were entered"); }