DOCTYPE html html lang en head meta charset UTF-8 meta name viewport c

 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<h4>Введіть перше число</h4>
<input type="button" id="firstNumber" value="Почати" onclick="taskOne();">
<script>
function taskOne() {
var a = prompt("Enter A(Must be positive)", 0);
var b = prompt("Enter B(Must be positive)", 0);
if((Math.sign(a) == 1) && (Math.sign(b) == 1)){
alert("Numbers are positive!");
}
else if((Math.sign(a) == 1) && (Math.sign(b) == -1) ){
alert("B is negative!");
b = +prompt("Enter B again!(Must be positive)", 0);
}
else if((Math.sign(a) == -1) && (Math.sign(b) == 1)){
alert("A is negative!");
a = +prompt("Enter A again!(Must be positive)", 0);
}
else if((Math.sign(a) == -1) && (Math.sign(b) == -1)){
alert("A and B are negative!");
a = +prompt("Enter A again!(Must be positive)", 0);
b = +prompt("Enter B again!(Must be positive)", 0);
}
let arr = [];
var c = Math.trunc(a/b);
var d = Math.min(a,b);
for(let i = 0; i < d; i++){
if(i%c == 0)
{
arr.push(i);
i++;
}
}
alert("Answer "+ arr );
}
</script>
<br><br>
</body>
</html>