123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227 |
- // const taskName = prompt('Enter task name');
- // switch (taskName) {
- // case 'switch: sizes': const sizeRus = prompt('enter size');
- // switch (sizeRus) {
- // case '40': alert('I 38, GB 8, USA 6');
- // break;
-
- // case '42': alert('I 40, GB 10, USA 8');
- // break;
-
- // case '44': alert('I 42, GB 12, USA 10');
- // break;
-
- // case '46': alert('I 44, GB 14, USA 12');
- // break;
-
- // case '48': alert('I 46, GB 16, USA 14');
- // break;
-
- // case '50': alert('I 48, GB 18, USA 16');
- // break;
- // };
- // break;
- // case 'switch: if': let color = prompt("Введите цвет","");
- // if (color === "red") {
- // document.write("<div style='background-color: red;'>красный</div>");
- // document.write("<div style='background-color: black; color: white;'>черный</div>");
- // }
- // else if (color === "black") {
- // document.write("<div style='background-color: black; color: white;'>черный</div>");
- // }
- // else if (color === "blue") {
- // document.write("<div style='background-color: blue;'>синий</div>");
- // document.write("<div style='background-color: green;'>зеленый</div>");
- // }
- // else if (color === "green") {
- // document.write("<div style='background-color: green;'>зеленый</div>");
- // }
- // else {
- // document.write("<div style='background-color: gray;'>Я не понял</div>");
- // };
- // break;
- // case 'prompt: or': const age = +(prompt('Your age')); console.log(age);
- // const yearPresent = 2021;
- // let ageNew;
-
- // if ( age == "" || age === null ) {
- // ageNew = +prompt('Please writing your age');
- // }; console.log(ageNew);
-
- // if (ageNew === null || ageNew == "") {
- // alert('It is not interested for you');
- // };
- // if (age !== "" || ageNew !== "" || typeof(age) === 'number') {
- // const yearBirth = yearPresent - ageNew;
- // const yearBirth1 = yearPresent - age;
- // alert(` ${yearBirth1} ${yearBirth}`);
- // };
- // break;
- // case 'confirm: or this days': const shoping = confirm('Shoping?'); console.log(shoping);
- // shoping || alert(`you are biaka`);
- // break;
-
- // case 'confirm: if this days': const shoping = confirm('Shoping?'); console.log(shoping);
- // if (shoping === false) {
- // alert(`you are biaka`);
- // };
- // break;
- // case 'triple prompt': const surname = prompt('enter surname');
- // const userName = prompt('enter name');
- // const patronymic = prompt('patronymic');
-
- // alert(`Full name ${surname} ${userName} ${patronymic} `);
- // break;
- // case 'default: or': const surname = prompt('enter surname');
- // const userName = prompt('enter name');
- // const patronymic = prompt('patronymic');
-
- // alert(`Full name ${surname || 'Ivanov'} ${userName || 'Ivanov'} ${patronymic || 'Ivanov'} `);
- // break;
- // case 'default: if': let surname = prompt('enter surname');
- // let userName = prompt('enter name');
- // let patronymic = prompt('patronymic');
- // //1)
- // if (surname === null || surname === "") {
- // surname = 'Ivanov';
- // };
- // if (userName === null || userName === ""){
- // userName = 'Ivanov';
- // };
- // if (patronymic === null || patronymic ==="") {
- // patronymic = 'Ivanov';
- // } ;
- // alert(`Full name ${surname} ${userName} ${patronymic} `);
-
- // //2)
- // if ((surname === null || surname === "") && (userName === null || userName === "") && (patronymic === null || patronymic ==="") ) {
- // alert('Ivanov Ivanov Ivanov');
- // } else if (surname === null || surname === "") {
- // surname = 'Ivanov';
- // alert(`Full name ${surname} ${userName} ${patronymic} `);
- // } else if (userName === null || userName === ""){
- // userName = 'Ivanov';
- // alert(`Full name ${surname} ${userName} ${patronymic} `);
- // } else if (patronymic === null || patronymic ==="") {
- // patronymic = 'Ivanov';
- // alert(`Full name ${surname} ${userName} ${patronymic} `);
- // } ;
- // break;
- // case 'login and password': const login = "admin";
- // const password = "qwerty";
- // const useLogin = prompt('Enter login');
- // let usePassword;
-
- // if (login === useLogin) {
- // usePassword = prompt('Enter password');
- // };
- // if (login !== useLogin || password !== usePassword) {
- // alert('Error');
- // } else alert('Good!');
- // break;
- // case 'currency calc': const currency = prompt('select currency: usd or eur' ).toLowerCase();
- // let monyHr;
- // switch (currency) {
- // case 'usd': monyHr = 27;
- // break;
- // case 'eur': monyHr = 30;
- // break;
- // };
- // const hryvnias = prompt('how much UAH');
- // alert(`${currency} ${hryvnias / monyHr}`);
- // break;
- // case 'currency calc: two rates': const currency = prompt('select currency: usd or eur' ).toLowerCase();
- // const question = confirm('Do You want to buy currency?');
- // const amount = prompt('Money');
- // let monyHr;
-
- // switch (currency) {
- // case 'usd': monyHr = 27;
- // break;
- // case 'eur': monyHr = 30;
- // break;
- // };
-
- // question ? alert(`${currency} ${amount / monyHr}`) : alert(`hryvnias ${amount * monyHr}`);
- // break;
- // case 'currency calc: if': const currency = prompt('select currency: usd or eur' ).toLowerCase();
- // const question = confirm('Do You want to buy currency?');
- // const amount = prompt('Money');
- // let monyHr;
-
- // if (currency === 'usd') {
- // monyHr = 27;
- // };
- // if (currency === 'eur') {
- // monyHr = 30;
- // };
- // if (question) {
- // alert(`${currency} ${amount / monyHr}`);
- // } else alert(`hryvnias ${amount * monyHr}`);
- // break;
- // case 'scissors': const things = ['rock', 'scissors', 'paper'];
- // const userThing = prompt('choose rock or paper or scissors');
- // const randomThings = things[ Math.floor(Math.random()*things.length)];
- // alert(randomThings);
-
- // if ((userThing === 'rock') && (randomThings === 'scissors')) {
- // alert('you are winner!');
- // } else if ((userThing === 'scissors') && (randomThings === 'paper')) {
- // alert('you are winner!');
- // } else if ((userThing === 'paper') && (randomThings === 'rock')) {
- // alert('you are winner!');
- // } else if (randomThings === userThing) {
- // alert('no one is a winner');
- // } else alert('you lose');
- // break;
- // case 'Задание на синий пояс': let ratios = {
- // usd: 25.6,
- // eur: 29
- // };
- // const currency = prompt('select currency: usd or eur' ).toLowerCase();
- // const question = confirm('Do You want to buy currency?');
- // const amount = prompt('Money');
- // const monyHr = ratios[currency];
-
- // question ? alert(`${currency} ${amount / monyHr}`) : alert(`hryvnias ${amount * monyHr}`);
- // break;
- // case 'real data': const amountMoney = prompt('Enter Money');
- // fetch('https://open.er-api.com/v6/latest/USD').then(res => res.json())
- // .then(data => {
- // console.log(data.rates.UAH)
- // alert(`UAN ${amountMoney * data.rates.UAH}`)
-
- // });
- // break;
- // };
- //Task
- const things = ['rock', 'scissors', 'paper'];
- const userThing = prompt('choose rock or paper or scissors');
- const randomThings = things[ Math.floor(Math.random()*things.length)];
- alert(randomThings);
- ((userThing === 'rock') && (randomThings === 'scissors') && !(alert('you are winner!'))) ||
- ((userThing === 'scissors') && (randomThings === 'paper') && !(alert('you are winner!'))) ||
- ((userThing === 'paper') && (randomThings === 'rock') && !(alert('you are winner!'))) ||
- ((randomThings === userThing) && !(alert('no one is a winner'))) ||
- !(alert('you lose'));
|