-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathЗадание
More file actions
43 lines (30 loc) · 1.02 KB
/
Copy pathЗадание
File metadata and controls
43 lines (30 loc) · 1.02 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
Завдання 1
function readNumber() {
const a = prompt('Enter num:')
if(a === '' || a === null) return null
else if(isNaN(+a)) return readNumber()
else return a
}
console.log(readNumber())
Завдання 2
function random(min, max) {
return Math.random() * (max - min) + min
}
for(let i = 0; i < 30; i++) console.log(random(1, 5))
Завдання 3
const a = +prompt('Enter num1:'),
b = +prompt('Enter num2:')
alert(a + b)
Завдання 4
let array=[
" Спочатку JavaScript був створений, щоб зробити веб-сторінки живими ",
" Різні двигуни мають різні «кодові імена».",
" Коли JavaScript створювався, він мав інше ім'я – «LiveScript» ",
" Повна інтеграція з HTML/CSS "
]
array.forEach(item => item.indexOf('JavaScript') !== -1 ? console.log(item) : undefined)
Завдання 5
function formatStr(str) {
return str = str[0].toUpperCase() + str.substr(1).toLowerCase()
}
formatStr('bOoK')