//ODD /* let number = +prompt('Write your number') if(number) { alert("Your number is " + number) } else { alert('You do not write the number') } if (number%2==0) { alert("It's even number") } else { alert("It's odd number") } //LEXICS let str = prompt("Write some text without number ") if (str.indexOf("1","2","3","4","5","6","7","8","9","0")){ alert("Perfect") } else { alert("You have some mistakes") } //BOOLEAN let sleep = confirm("Are you sleep today?") let food = confirm("Are you eat today?") alert(food, sleep) //IF let gender = confirm("Are you man?") if(gender) { alert("You are man") } else { alert("You are woman") } //Sizes let size = +prompt("Write your size of outerwear?(In USA)") + 2 if(size){ alert("Your size in UK: " + size) //United Kingdom } else { alert("Write a number") } let secondsize = confirm("Обхват вашей талии 63 - 65 см?") && confirm("Обхват ваших бедер 89-92 см?") if(secondsize){ alert("Ваш размер XS") } else { alert("Ваш размер больше XS") } //TERNARY let gender = confirm("Are you woman?") ? alert("woman") : alert("man") //PROMPT: OR let age = +prompt ('How old are you?') || alert("Write correct number" ) let year = (2022 - age ) alert("You were born in " + year) //CONFIRM: OR THIS DAY let shop = confirm("Shoping?") || alert("You are БЯКА") //CONFIRM: IF THIS DAY let shop = confirm("Shoping?") if(shop){ alert("Let's go") } else{ alert("You are БЯКА") } //Default: or { let name = prompt("Write your name") || String(" Ivan") let surname = prompt("Write your surname") || String(" Ivanov") let patronymic = prompt("Write your patronymic") || String(" Ivanovic") alert(name + surname + patronymic) } //Default: if { let name = prompt("Write your name") let surname = prompt("Write your surname") let patronymic = prompt("Write your patronymic") if(name){ } else{ name = String("Ivan") } if(surname){ } else{ surname = String(" Ivanov") } if(patronymic){ } else{ patronymic = String(" Ivanovic") } alert(name + surname + patronymic) } //Login and password let login = prompt("Write your login") let password = prompt("Write your password") if(login===String("admin") && password===String("qwerty")){ alert("Exactly") } else{ alert("You did mistakes in login or password") }*/ /* //Currency exchange let money = prompt("Choose and write down what currency you need to change \n (\"usd\" , \"eur\" , \"pln\")").toUpperCase() let amount = +prompt("How amount of money you want to change?") || alert("write correctly") let result , rateBuy , rateSell if(money===String("USD") || money===String("EUR") || money===String("PLN")){ } else{alert("Update page and write correctly!")} if(money===String("USD")){ let change = confirm("You want to sell or buy") ? "sell" : "buy" if(change==="sell"){ rateSell = 36.9 result = rateSell * amount alert("You will get : " + result + " UAH" ) } else{ rateBuy = 38.9 result = rateBuy * amount alert("You need : " + result + " UAH" ) } } if(money===String("EUR")){ let change = confirm("You want to sell or buy") ? "sell" : "buy" if(change==="sell"){ rateSell = 36 result = rateSell * amount alert("You will get : " + result + " UAH" ) } else{ rateBuy = 38 result = rateBuy * amount alert("You need : " + result + " UAH" ) } } if(money===String("PLN")){ let change = confirm("You want to sell or buy") ? "sell" : "buy" if(change==="sell"){ rateSell = 7.57 result = rateSell * amount alert("You will get : " + result + " UAH" ) } else{ rateBuy = 9.57 result = rateBuy * amount alert("You need : " + result + " UAH" ) } } /* Second variant let secondmoney = prompt("Choose and write down what currency you need to get \n (\"usd\" , \"eur\" , \"uah\")").toUpperCase() let rate,result let amount = +prompt("How amount of money you want to change?") || alert("write correctly") if(money===String("USD")){ if(secondmoney===String("EUR")){ rate = 1.02 } else{rate = 36.90} } if(money===String("EUR")){ if(secondmoney===String("USD")){ rate = 0.98 } else{rate = 36.02} } if(money===String("UAH")){ if(secondmoney===String("USD")){ rate = 0.027 } else{rate = 0.028} } let change = confirm("You want to change") ? "yes" : "not" if(change=="yes"){ result = amount * rate } alert(result + " : " + secondmoney) */ /* //Scissors let choise = +prompt("Write number of your power : \n 1- Stone \n 2-Scissors \n 3-Paper ") let randomPc = Math.ceil(Math.random() * 3) //Pc choise if(choise===1 && randomPc===2){ //STONE alert("You win") } if(choise===1 && randomPc===3){ alert("You losed") } if(choise===1 && randomPc===1){ alert("Draw") } if(choise===2 && randomPc===3){ //SCISSORS alert("You win") } if(choise===2 && randomPc===1){ alert("You losed") } if(choise===2 && randomPc===2){ alert("Draw") } if(choise===3 && randomPc===1){ //PAPER alert("You win") } if(choise===3 && randomPc===2){ alert("You losed") } if(choise===3 && randomPc===3){ alert("Draw") } */ let exc = prompt("Write name of exercise").toUpperCase() if(exc === "NUMBER:ODD"){ let number = +prompt('Write your number') if(number) { alert("Your number is " + number) } else { alert('You do not write the number') } if (number%2==0) { alert("It's even number") } else { alert("It's odd number") } } if(exc === "STRING:LEXICS"){ let str = prompt("Write some text without number ") if (str.indexOf("1","2","3","4","5","6","7","8","9","0")){ alert("Perfect") } else { alert("You have some mistakes") } } if(exc === "BOOLEAN"){ let sleep = confirm("Are you sleep today?") let food = confirm("Are you eat today?") alert(food, sleep) //IF let gender = confirm("Are you man?") if(gender) { alert("You are man") } else { alert("You are woman") } } if(exc === "BOOLEAN:IF"){ let gender = confirm("Are you man?") if(gender) { alert("You are man") } else { alert("You are woman") } } if(exc === "COMPARISON:SIZE"){ let size = +prompt("Write your size of outerwear?(In USA)") + 2 if(size){ alert("Your size in UK: " + size) //United Kingdom } else { alert("Write a number") } let secondsize = confirm("Обхват вашей талии 63 - 65 см?") && confirm("Обхват ваших бедер 89-92 см?") if(secondsize){ alert("Ваш размер XS") } else { alert("Ваш размер больше XS") } } if(exc === "TERNARY"){ let gender = confirm("Are you woman?") ? alert("woman") : alert("man") } if(exc === "PROMPT:OR"){ let age = +prompt ('How old are you?') || alert("Write correct number" ) let year = (2022 - age ) alert("You were born in " + year) } if(exc === "CONFIRM:OR THIS DAY"){let shop = confirm("Shoping?") || alert("You are БЯКА")} if(exc === "CONFIRM:IF THIS DAY"){ let shop = confirm("Shoping?") if(shop){ alert("Let's go") } else{ alert("You are БЯКА") } } if(exc === "DEFAULT:OR"){ { let name = prompt("Write your name") || String(" Ivan") let surname = prompt("Write your surname") || String(" Ivanov") let patronymic = prompt("Write your patronymic") || String(" Ivanovic") alert(name + surname + patronymic) } } if(exc === "DEFAULT:IF"){ let name = prompt("Write your name") let surname = prompt("Write your surname") let patronymic = prompt("Write your patronymic") if(name){ } else{ name = String("Ivan") } if(surname){ } else{ surname = String(" Ivanov") } if(patronymic){ } else{ patronymic = String(" Ivanovic") } alert(name + surname + patronymic) } if(exc === "LOGIN AND PASSWORD"){ let login = prompt("Write your login") let password = prompt("Write your password") if(login===String("admin") && password===String("qwerty")){ alert("Exactly") } else{ alert("You did mistakes in login or password") } } if(exc === "CURRENCY EXCHANGE"){let money = prompt("Choose and write down what currency you need to change \n (\"usd\" , \"eur\" , \"pln\")").toUpperCase() let amount = +prompt("How amount of money you want to change?") || alert("write correctly") let result , rateBuy , rateSell if(money===String("USD") || money===String("EUR") || money===String("PLN")){ } else{alert("Update page and write correctly!")} if(money===String("USD")){ let change = confirm("You want to sell or buy") ? "sell" : "buy" if(change==="sell"){ rateSell = 36.9 result = rateSell * amount alert("You will get : " + result + " UAH" ) } else{ rateBuy = 38.9 result = rateBuy * amount alert("You need : " + result + " UAH" ) } } if(money===String("EUR")){ let change = confirm("You want to sell or buy") ? "sell" : "buy" if(change==="sell"){ rateSell = 36 result = rateSell * amount alert("You will get : " + result + " UAH" ) } else{ rateBuy = 38 result = rateBuy * amount alert("You need : " + result + " UAH" ) } } if(money===String("PLN")){ let change = confirm("You want to sell or buy") ? "sell" : "buy" if(change==="sell"){ rateSell = 7.57 result = rateSell * amount alert("You will get : " + result + " UAH" ) } else{ rateBuy = 9.57 result = rateBuy * amount alert("You need : " + result + " UAH" ) } } } if(exc === "SCISSORS"){ let choise = +prompt("Write number of your power : \n 1- Stone \n 2-Scissors \n 3-Paper ") let randomPc = Math.ceil(Math.random() * 3) //Pc choise if(choise===1 && randomPc===2){ //STONE alert("You win") } if(choise===1 && randomPc===3){ alert("You losed") } if(choise===1 && randomPc===1){ alert("Draw") } if(choise===2 && randomPc===3){ //SCISSORS alert("You win") } if(choise===2 && randomPc===1){ alert("You losed") } if(choise===2 && randomPc===2){ alert("Draw") } if(choise===3 && randomPc===1){ //PAPER alert("You win") } if(choise===3 && randomPc===2){ alert("You losed") } if(choise===3 && randomPc===3){ alert("Draw") } }