var a = 5; var b, c; b = (a * 5); b = (c = b/2); // Выражение 2 -это выражение литерального значения // b - это выражение переменной // b/2 - это арифметическое выражение //c = b/2, b = (c = b/2) - это выражение присваивания // Расставим скобки // b = (c = ((a*5)/2)); // Порядок вычисления // 1. объявляется переменная a и ей присваивается число 5 // 2. объявляется переменные b, c // 3. вычисляется выражение а * 5 = 25 и присваивается b // 4. вычисляется выражение b /2 = 12.5 и присваивается c // 5. 12.5 присваивается b // console.log(a); // console.log(b); // console.log(c); //Task 2 // console.log(1) alert(1) Uncaught SyntaxError: Unexpected identifier // console.log('ошибка') // [1, 2].join('') VM260:2 Uncaught TypeError: Cannot read properties of undefined //Task Number: age // function showYearBirth () { // let age = +(prompt('Your age')); // let yearPresent = 2021; console.log(age); // if ( age == 0 || isNaN(age)) { // age = prompt('Please writing your age'); console.log(age); // } else if ( age !== null) { // let yearBirth = yearPresent - age; // alert(yearBirth); // }; // alert ('You are not interested'); // return; // }; // showYearBirth(); // Task Number: temperature // function showNumberTemperature () { // let unit = confirm('We transfer the temperature to Faringate'); // const faringate = 32; // let temperature; // if (unit) { // temperature = prompt('how many degrees celsius')*faringate; // alert(`Faringate degrees ${temperature}`); // return; // }; // temperature = prompt('how many degrees Faringate')/32; // alert(`Celsius degrees ${temperature}`); // }; // showNumberTemperature (); // Task Number: divide // let numb1 = prompt('enter the first number'); // let numb2 = prompt('enter the second number'); // let calculationInteger = (a, b) => { // let integer = Math.floor(a/b); // alert(integer); // return; // }; // calculationInteger (numb1, numb2); // Task Number: odd // let oddnumber = +prompt('Enter number'); // function checkOddNumber () { // if (typeof(oddnumber) !== 'number' || isNaN(oddnumber)){ // alert('It is not a number'); // return; // }; // alert('Good!'); // if (oddnumber%2 == 0) { // alert(`${oddnumber} it is an even number `); // return; // }; // alert('it is not an even number'); // }; // checkOddNumber (); //Task String: greeting // let yourname = prompt('What is your name?'); // alert(`Welcome ${yourname}`); //Task String: lexics // const words = prompt('write a word').split(' '); console.log(words); // const badwords = prompt('write bad words').split(' ');console.log(badwords); // for (let i = 0; i < badwords.length; i++) { // if (words.includes(badwords[i])) { // alert(`${badwords[i]} bad word`); // } // }; // Task confirm // const x = confirm('You are a woman'); // console.log(typeof(x)); // console.log(x); // if (x) { // alert('woman'); // } else { // alert('Man'); // }; //Task Array: booleans // const arr = []; // for (let i=0; i<5; i++) { // const meaning = confirm('enter number'); // arr[i] = meaning; // }; // console.log(arr); // Task Array: plus // const arr = [1, 5, 3]; // arr[2] = arr[0] + arr[1]; // console.log(arr); //Task Array: plus string // const arr = [1, 'bbb', 3]; // let sum = 0; // for (let i = 0; i < arr.length; i++) { // sum += arr[i]; // }; // console.log(sum); // Task Object: real, Object: change // const earrings = { // metal: 'gold', // weight: 5, // proba: 999, // color: 'yellow', // stone: " ", // }; // console.log(earrings ); // earrings.metal = 'silver'; // earrings['stone'] = 'Diamond'; // console.log(earrings); //Task Comparison if // var age = +prompt("Сколько вам лет?",""); // if (age < 0) { // alert("то ли киборг, то ли ошибка"); // } else if (age < 18){ // alert("школьник"); // } // else if (age < 30){ // alert("молодеж"); // } // else if (age < 45){ // alert("зрелость"); // } // else if (age < 60){ // alert("закат"); // } // else if (age > 60){ // alert("как пенсия?"); // }; //Task Comparison: sizes // const size = { // rus: [40, 42, 44, 46, 48, 50, 52, 54], // italy: [38, 40, 42, 44, 46, 48, 50, 52], // usa: [6, 8 ,10, 12, 14, 16, 18, 20], // }; // const country = prompt('select country (Italy USA)').toLowerCase(); // if (country === 'italy') { // alert(size.italy); // } else // alert(size.usa); // Task Ternary //const gender = confirm('Can i find your gender') ? (alert('you are a woman?') ? "" : alert('you are a man?') ):alert('goodbye'); // Task Синий пояс Number: flats function defineNumberFlat (floor, countFlatOnFloor, numberFlat) { const countFlatInEntranse = floor * countFlatOnFloor; const entranse = Math.ceil(numberFlat / countFlatInEntranse); const floorNumber = Math.ceil((numberFlat % countFlatInEntranse) / countFlatOnFloor); if (numberFlat % countFlatInEntranse === 0 ) { console.log (`Number entranse ${entranse}`); console.log (`Number floor ${numberFlat / entranse / countFlatOnFloor}`); return; } console.log (`Number entranse ${entranse}`); console.log (`Number floor ${floorNumber}`); }; defineNumberFlat (9, 4, 2);