123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152 |
- <!DOCTYPE html>
- <html>
- <head>
- <title>Задачки</title>
- <meta charset="utf-8">
- </head>
- <body>
- <script>
- //assign: evaluation
- /*var a=5;
- var b,c;
- b= (a*5);
- b= (c=(b/2));
- console.log(b);
- console.log(c);*/
- //----------------------------------------
- console.log(2 || 1); //2
- console.log(2 || 0); //2
- console.log(0 || 2); //2
- console.log(0 && 2); //0
- console.log(2 && 0); //0
- console.log(2 && 1); //1
- console.log(2 && 1 && 0); //0
- console.log(2 || 1 || 0); //2
- console.log(4 && 5 || false); //1
- console.log(1 || 0 && 2); //1
- //Number: age
- /*let date =new Date().getFullYear();
- let age=+prompt('','');
- let f=date-age;
- alert(f);*/
- //Number: temperature
- //((...°C × 9/5) + 32 = ...°F)
- /*let czelsii=prompt('°C','')
- let faren= czelsii * 9/5 + 32;
- alert(faren+'°F');*/
- //Number: divide
- /*let num1=+prompt('','');
- let num2=+prompt('','');
- alert(Math.round(num1)/Math.round(num2));*/
- //Number: odd
- /*let n=+prompt('','');
- if(isNaN(n)){
- alert(new Error(' Дичь какая-то'));
- }else{
- if(n%2==0){
- alert('Number: '+ n +' (четное)');
- }else{
- alert('Number: '+n+' (нечетное)');
- }
- }*/
- //String: greeting
- /*let name=prompt('Your name: ','');
- alert('Hello, '+name);*/
-
- //String: lexics
- /*let badWords=['хуй','лох','дурак'];
- let text=prompt('Your text:','');
- for(let i=0;i<badWords.length;i++){
- if(text.includes(badWords[i])){
- alert(new SyntaxError('Следи за языком!'));
- break;
- }
- }*/
- //confirm
- /*let y=confirm('');
- alert(typeof y);*/ //boolean
-
- //Boolean || Boolean: if
- /*let y2=confirm('Вы мужчина?');
- if(y2){
- alert('You are a man');
- }else{
- alert('That is mean that you are a woman');
- }*/
-
- //Array: booleans
- /*let y2=confirm('Вы мужчина?');
- let y3=confirm();
- let y4=confirm();
- let y5=confirm();
- let arr=[y2,y3,y4,y5];
- console.log(arr);*/
- //Array: plus
- /*let arr=[+prompt('',''),+prompt('','')];
- let sum=arr.reduce((s,cur)=>s+=cur);
- arr.push(sum);
- console.log(arr);*/
- //Array: plus string
- /*let arr=['Hello,',' Mr.',' President'];
- let sum=arr.reduce((s,cur)=>s+=cur);
- console.log(sum);*/
- //Comparison sizes
- /*let sizes={
- '40':'6 или L',
- '42':'8 или M',
- '44':10,
- '46':'12 или L',
- '48':14,
- '50':'16 или XL',
- '52':18,
- '54':'20 или XXL'
- };
- let key = prompt('Какой размер перевести вам в USA?','');
- alert(sizes[key]);*/
- //Ternary
- /*confirm('Мужчина или Женщина ?')?alert('Мужчина'):alert('Женщина');*/
- //-----------------BluBELT--------------------------------
-
- let house={
- firstPadik:[1,2,3,4,5,6,7,8,9],
- secondPadik:[10,11,12,13,14,15,16,17,18],
- thirdPadik:[19,20,21,22,23,24,25,26,27],
- fourthPadik:[28,29,30,31,32,33,34,35,36]
- };
- let apart=+prompt('Введите номер квартиры','');
- let l=0;
- for(key in house){
- for(let i=0;i<9;i++){
- if(apart<=house[key][i]*4 ){
- l++;
- alert(key+" - "+[++i]+' этаж');
- break;
- }
- }
- if(l==1){
- break;
- }else{
- continue;
- }
- }
-
- </script>
- </body>
- </html>
|