diff --git a/HomeWork/js/script.js b/HomeWork/js/script.js index 215a3b4..301b8f6 100644 --- a/HomeWork/js/script.js +++ b/HomeWork/js/script.js @@ -5,6 +5,13 @@ // Скопіюйте значення зі змінної name в city. // Виведіть значення змінної city, використовуючи функцію console.log (яка повинна показати “Іван”). +// let name; +// let city; + +// name = "Іван"; +// city = name; +// console.log(city); + //***2*** //Який буде результат виконання скрипта? // let name = "Olga"; @@ -12,6 +19,11 @@ // console.log(`привіт ${"name"}`); // // console.log(`привіт ${name}`); // ? +// let name = "Olga"; +// console.log(`привіт ${1}`); // привіт 1 +// console.log(`привіт ${"name"}`); // привіт name +// console.log(`привіт ${name}`); // привіт Ольга + //***3*** //Видобути число зі змінних // let a = "5"; @@ -19,22 +31,35 @@ // let c = "12.9sxdcfgv"; // вивести в консоль тип +// console.log(typeof Number(a)); +// console.log(typeof parseInt(b)); +// console.log(typeof parseFloat(c)); + //***4*** //Зробіть, щоб 0.1 + 0.2 = 0.3 +// console.log((0.1 * 10 + 0.2 * 10) / 10); + //***5** //Поверніть найбільше число с набору 20, 10, 50, 40 +// console.log(Math.max(20, 10, 50, 40)); + //***6** //Поверніть випадкове число в діапазоні від 2 до 4 +// console.log(Math.random() * (4 - 2) + 2); + //***7** //дізнатись довжину message -// const message = "Welcome to Bahamas!"; +const message = "Welcome to Bahamas!"; +// console.log(message.length); //19 //***8** //вивести в консоль message великими літерами +// console.log(message.toUpperCase()); + //***9** // створити пустий об*єкт // додати туди ім*я, вік і місто @@ -43,5 +68,19 @@ // додати буль з ключем: like flowers // вивести результат в консоль +let person = {} +person.name = "Yan"; +person.age = 19; +person.city = "Kryvyi Rih"; +console.log(person); +delete person.city; +person["like flowers"] = true; +console.log(person); + //***10** // За допомогою циклу “for…in” вивести в консоль ключі і значення об*єкта + +for (key in person) { + console.log(key); + console.log(person[key]); +}