// Additional task var additionalTask = prompt("switchSizes, switch:if, prompt:or, confirm: or this days, confirm: if this days, triple prompt, default: or, default: if, login and password, currency calc && currency calc: improved, currency calc: two rates, currency calc: if, target, blue belt assignment'") switch(additionalTask) { case 'switch:sizes' : let size = prompt('Enter your size', " "); switch(size) { case '40' : alert('Your size in Norvay 34 S'); break; case '42' : alert('Your size in Norvay 36 M'); break; case '44' : alert('Your size in Norvay 38'); break; case '46' : alert('Your size in Norvay 40 L'); break; case '48' : alert('Your size in Norvay 42'); break; case '50' : alert('Your size in Norvay 44 XL'); break; case '52' : alert('Your size in Norvay 46'); break; case '54' : alert('Your size in Norvay 54 XXL'); break; default : alert('Sorry but you size not included in our table'); } break; case 'switch:if' : var color = prompt("Введите цвет",""); if (color == "red") { document.write("
красный
"); document.write("
черный
"); } else if (color == "black") { document.write("
черный
"); } else if (color == "blue") { document.write("
синий
"); document.write("
зеленый
"); } else if (color == "green"){ document.write("
зеленый
"); } else{ document.write("
Я не понял
"); } break; case 'prompt:or' : var yearNow = 2020; var personYears; var howOldPerson = +prompt('Сколько вам лет') || alert('Error'); var personYears = yearNow - howOldPerson; if(howOldPerson!=null) alert('You born in ' +personYears ); break; case 'confirm: or this days' : var shoping = confirm('Shoping?') || alert('You are a caca'); alert('You are the best'); break; case 'confirm: if this days' : let soping = confirm('Shoping?'); if (soping==false) { alert('You are a caca'); } else {alert('You are the best'); } break; case 'triple prompt' : var name = prompt("Enter you name", ""); var surname = prompt("Enter you surname", ""); var fathername = prompt("Enter you fathername", ""); alert(name + ' ' + surname + ' ' + fathername); break; case 'default: or' : var name = prompt("Enter you name") || "Ivan"; var surname = prompt("Enter you surname") || "Ivanov"; var fatherName = prompt("Enter you fathername") || "Ivanovich"; alert(surname + ' ' + name + ' ' + fatherName); break; case 'default: if' : var surnameOne = prompt("Enter you surname"); var nameOne = prompt("Enter you name"); var fatherNameOne = prompt("Enter you fathername"); if (!surnameOne) { surnameOne = 'Ivanov'} if (!nameOne) {nameOne = 'Ivan'} if (!fatherNameOne) {fatherNameOne = 'Ivanovich'} alert(surnameOne + ' ' + nameOne + ' ' + fatherNameOne); break; case 'login and password' : var name = 'stas'; var nameTwo = 'alex'; var nameThree = 'pety'; var passworld = 1234; var passworldTwo = 777; var passworldThree = 'qwerty' var loginName = prompt("Enter you name", "") || alert("Enter you name") var loginPassworld = prompt("Enter you passworld", "") || alert("Enter you passworld") if (name!==loginName && passworld==loginPassworld || nameTwo!==loginName && passworldTwo==loginPassworld || nameThree!==loginName && passworldThree==loginPassworld){ alert("Wrong name") } else if(name==loginName && passworld!==loginPassworld || nameTwo==loginName && passworldTwo!==loginPassworld || nameThree==loginName && passworldThree!==loginPassworld ){ alert('Passworld is wrong') } else if (name==loginName && passworld==loginPassworld || nameTwo==loginName && passworldTwo==loginPassworld || nameThree==loginName && passworldThree==loginPassworld){ alert("Cam in") } else if (name!=loginName && passworld!=loginPassworld) { alert('anncorect name and passworld') }else {alert('Cansel')} break; case 'currency calc && currency calc: improved' : var сurrency = prompt("Enter you currency usd or eur").toLowerCase(); switch(сurrency) { case "usd" : currency = 29 break; case "eur" : currency = 33 } var sum = + prompt("Enter the amount you want to transfer to UAH"); var dubget = sum * currency alert(dubget) break; case 'currency calc: two rates' : var сurrency = prompt("Enter you currency usd or eur").toLowerCase(); switch(сurrency) { case "usd" : currency = 29 break; case "eur" : currency = 33 } var sum = + prompt("Enter the amount you want to transfer"); var dubget = confirm("Click OK if you want to sell or Cancel if you want to buy") ? dubgett = sum * currency : dubggett = sum / currency; alert(dubget) break; case 'currency calc: if' : var currencyUsd = 29; var currencyEur = 33 var currencyOne = prompt("Enter you currency usd or eur").toLowerCase(); var sum = + prompt("Enter the amount you want to transfer"); var dubgett = confirm("Click OK if you want to sell or Cancel if you want to buy") if (currencyOne === "usd" && sum>0 && dubgett) { var summa = sum * currencyUsd} if (currencyOne === "usd" && sum>0 && !dubgett) {var summa = sum / currencyUsd} if (currencyOne === "eur" && sum>0 && dubgett) {var summa = sum * currencyEur} if (currencyOne === "eur" && sum>0 && !dubgett) {var summa = sum / currencyEur} alert(summa) break; case 'scissors' : var game = prompt("Choose one from rock, scissors, paper").toLowerCase(); var enemy = Math.floor(Math.random()*3); if (enemy == 0) {enemy = "rock"} {if (enemy == "rock" && game == "paper") alert("You have won")} {if (enemy == "rock" && game == "rock") alert("Draw")} {if (enemy == "rock" && game == "scissors") alert("Opponent defeated")} if (enemy == 1) {enemy = "paper"} {if (enemy == "paper" && game == "paper") alert("Draw")} {if (enemy == "paper" && game == "rock") alert("Opponent defeated")} {if (enemy == "paper" && game == "scissors") alert("You have won")} if (enemy == 2 ) {enemy = "scissors"} {if (enemy == "scissors" && game == "paper") alert("Opponent defeated")} {if (enemy == "scissors" && game == "rock") alert("You have won")} {if (enemy == "scissors" && game == "scissors") alert("Draw")} break; case 'blue belt assignment' : var ratios = { usdSell: 25.6, eurSell: 29, usdBay: 27.8, eurBay: 31, } var currency = prompt("Enter you currency usd or eur").toLowerCase(); var sum = +prompt("Enter the amount you want to transfer"); let cashUsbSell = sum * ratios["usdSell"]; let cashUsdBay = sum/ratios["usdBay"]; let cashEurSell = sum * ratios["eurSell"]; let cashEurBay = sum/ratios["eurBay"]; if (currency == 'usd') confirm("Click OK if you want to sell or Cancel if you want to buy") ?alert("Your cash on sale is" + " " + cashUsbSell) : alert("Your cash from the purchase is" + " " + cashUsdBay); if (currency == 'eur') confirm("Click OK if you want to sell or Cancel if you want to buy") ?alert("Your cash on sale is" + " " + cashEurSell) : alert("Your cash from the purchase is" + " " + cashEurBay); break; case 'target' : // Написать программу которая будет склонять слово товар в зависимости от количества // товаров в корзине. Например 1 - товар, 4 - товара, 6 - товаров. var target = ['товар', 'товаров', 'товара'] var number = + prompt("Введите количество товаров") tipe = Math.abs(number%100) var numbers = tipe%10 if (tipe>10 && tipe<20 || numbers>4 && numbers<11) { alert(number + ' ' + target[1]) }else if (numbers > 1 && numbers < 5) { alert(number + ' ' + target[2]) }else if (numbers == 1) { alert(number + ' ' + target[0]) }else if (numbers == 0 ) {alert(number + ' ' + target[1])}else {alert("error")} break; }