Repository navigation
Expand file tree
/
Copy pathlesson-6.js
More file actions
85 lines (57 loc) · 2.36 KB
/
Copy pathlesson-6.js
File metadata and controls
85 lines (57 loc) · 2.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
// Lesson 6
// const in Javascript
// const нельзя изменить и всегда пишется с большой буквы
// если объект объявить ч-з const то его можно измнить.
// const PI = 3.14159;
// PI = 2.322;
// console.log(PI);
// let radius; // радиус
// let circumference; // длина окружности
// radius = prompt('Enter the radius of a circle: ');
// radius = Number(radius);
// circumference = 2 * PI * radius;
// console.log(radius, typeof radius);
// console.log('The circumference of a circle is', circumference);
// alert('The circumference of a circle is ' + circumference);
// Как решить эту задачу через функцию
// const PAI = 3.14159;
// function circumference(PI, radius) {
// return 2 * PI * radius;
// }
// // let result = circumference(PAI, 5);
// // let result = circumference(PAI, 15);
// let result = circumference(PAI, 10);
// console.log(result);
// Math objects in Javascript
// let x = -3.14;
// let y = 5;
// let z = 11;
// let maximum;
// let minimum;
// x = Math.PI; // число Пи, константа
// x = Math.round(x); // округляет по общему математическому правилу
// x = Math.floor(x); // округляет в меньшую сторону
// x = Math.ceil(x); // округляет в большую сторону
// x = Math.pow(x, 5); // возвышает в степень (x **= 2; // x = x ** 2)
// x = Math.sqrt(x); // корень числа
// x = Math.SQRT2; // корень из 2
// x = Math.SQRT1_2; // корень из 1/2
// x = Math.abs(x); // модуль числа х
// console.log(x);
// maximum = Math.max(x, y, z); // возвращает число с макс. значением
// minimum = Math.min(x, y, z); // возвращает число с мин. значением
// console.log('Max value: ', maximum);
// console.log('Min value: ', minimum);
// x = 0.2;
// y = 0.4;
// console.log((x + y));
// console.log((x + y).toFixed(15));
// Задача
// let num1 = prompt('Enter side A of a right triangle: ');
// let num2 = prompt('Enter side B of a right triangle: ')
// function calcSqrt(a, b) {
// return Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2));
// }
// let result = calcSqrt(num1, num2);
// console.log('Side C is: ', result);
// alert('Side C is: ' + result);