123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <title>Exercises</title>
- </head>
- <body>
- <script>
- let exercise=prompt('','');
- switch(exercise){
- case 'switch: sizes':
- let size=prompt('Введите размер','');
- switch(size){
- case '40':alert('6 или L');
- break;
- case '42':alert('8 или M');
- break;
- case '44':alert('10');
- break;
- case '46':alert('12 или L');
- break;
- case '48':alert('14');
- break;
- case '50':alert('16 или XL');
- break;
- case '52':alert('18');
- break;
- case '54':alert('20 или XXL');
- break;
- }
- break;
- case 'prompt: or':prompt('Введите возраст','')||alert(new Error('Error'));
- break;
- case 'confirm: or this days':confirm('Shopping?')||alert('Ты - бяка');
- break;
- case 'confirm: if this days':
- if(confirm('Shopping?')){
- alert('oK');
- }else{
- alert('Ты - бяка');
- }
- break;
- case 'triple prompt,default: or':
- let name=prompt('name','')||'John';
- let secondName=prompt('secondName','')||'Johnson';
- let surname=prompt('surname','')||'Pupkovich';
- alert(name+' '+secondName+' '+surname);
- break;
- case 'default: if':
- let Name=prompt('name','');
- if(Name==0||Name==undefined){
- Name='John'
- }
- let secondName2=prompt('secondName','');
- if(secondName2==0||secondName2==undefined){
- secondName2='Johnson';
- }
- let surname2=prompt('surname','');
- if(surname2==0||surname2==undefined){
- surname2='Pupkovich';
- }
- alert(Name+' '+secondName2+' '+surname2);
- break;
- case 'login and password':
- let name3='John';
- let pass='qwerty';
- let ask=prompt('Your name?','');
- if(ask!==name3){
- alert('Error name OR pass ...');
- }else{
- let ask2=prompt('Your password?');
- if(ask2!==pass){
- alert('Error name OR pass ...');
- }else{
- alert('Congratulation');
- }
- }
- break;
- case 'scissors':
- let ask2=prompt('Камень, нижницы или бумага ?','');
- let answer='';
- let num=Math.round(Math.random()*10);
- if(num>0&&num<=3){
- answer='камень';
- }else{
- if(num>=4&&num<=7){
- answer='бумага';
- }else{
- answer='ножницы';
- }
- }
- console.log(answer);
- if(ask2==answer){
- alert('Вы выиграли');
- }else{
- alert('Вы проиграли ');
- }
- break;
- }
- //Black belt
- let key2=Math.random();
- let key=key2>0.1&&key2<=0.4?'ножницы': key2>0.5? 'бумуга': 'камень';
- console.log(key);
- </script>
- </body>
- </html>
|