Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lesson 5 #120

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions lesson_3/index.html
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Homework</title>
<meta charset="UTF-8">
<script src="js/js.js"></script>
<title>Yuliia</title>
</head>
<body>


<script src="js/index.js"></script>

</body>
</html>
1 change: 0 additions & 1 deletion lesson_3/js/index.js

This file was deleted.

59 changes: 59 additions & 0 deletions lesson_3/js/js.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
//Задача 1

let a = 1;
let b = 2;

b = b - a;
a = b + 1;

console.log('Ответ на первую задачу');
console.log('Variable a =', a);
console.log('Variable b =', b);


//Задача 2

/*var numbA = prompt('Введите число а');
var numbB = prompt('Введите число b');

if (numbA > numbB){
alert(numbA);
} else {
alert(numbB);
}*/

//Задача 3

/*let c = prompt('Введите номер квартиры');
if(c > 0 && c <= 20){
alert('Первый подъезд');
}else if (c > 20 && c <= 48){
alert('Второй подъезд');
}else if (c > 48 && c <= 90){
alert('Третий подъезд');
} else {
alert('Таких нет');}*/

//Задача 4

/*let d = prompt('Введите год рождения');
let age = 2019 - d;
if(age >= 16){
alert('Добро пожаловать');
} else {
alert('Вход воспрещен!!!');
}*/

//Задача 5

let x = +prompt('Введите число');
if(x < -2){
x = 3*(x * x) - 8;
}else if(x >= -2 && x <= 4){
x = -9*(x * x) - 12;
}else {
x = 32 + x;
}

console.log('Ответ на 5 задачу');
console.log('Вывод функции =', x);
78 changes: 77 additions & 1 deletion lesson_5/js/index.js
Original file line number Diff line number Diff line change
@@ -1 +1,77 @@
'use strict'
'use strict'


//1

let arr = [1, 2, 3, 4];
let arr1 = [];
for (var i = 0; i < arr.length; i++) {
arr1[i] = arr[i].length;
arr1[i] = i + 4;
}

console.log(arr1);

//2

let arr3 = [1, 2, 3];
arr3.push(4, 5);
console.log(arr3);

//3

let array = [1, 2, 3, 4, 5, 6];
let array1 = 0;
for (let i = 0; i < array.length; i++) {
array1 += array[i];
};
let news = array1 / array.length;
console.log(news);

//4

let user = {
name: "Yuliia",
surname: "Kobets",
age: 26
}

console.log(user.name + " " + user.surname + " " + user.age);

//5

let keys = ["key1", "key2", "key3", "key4", "key5"];
let values = ["value1", "value2", "value3", "value4", "value5"];
let obj = {};

for (let i = 0; i < keys.length; i++) {
obj[keys[i]] = values[i];
}

console.log(obj);

//6

let num = 5;
let res = 0;
while (num < 1000) {
res = res + 1;
num = num * 2;
}

console.log("Количество итераций: " + res, "Pезультат: " + num);

//7

function sum() {
let result = 0;

for (let i = 0; i < arguments.length; i++) {
result += arguments[i];
}
return result;
}

let b = sum(1, 2, 5);

console.log(b);