-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex3.html
More file actions
60 lines (53 loc) · 1.21 KB
/
index3.html
File metadata and controls
60 lines (53 loc) · 1.21 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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<title> Startng Js task 3
</title>
<body>
</body>
<script type="text/javascript">
//declare the function
function integer(x) {
//initiate variable/array
var Array=[];
var string;
//using for loop to check elements from 1 to inputed integer value
for(y=1; y<=x; y++){
// conditions for element
if (y%2 == 0){
string = "yu";
}
if (y%3 == 0){
string = "gi";
}
if (y%5 == 0){
string= "oh";
}
if (y%2 == 0 && y%3 == 0 && y%5 != 0){
string= "yu-gi";
}
if (y%2 == 0 && y%3!= 0 && y%5 == 0){
string= "yu-oh";
}
if (y%2!= 0 && y%3 == 0 && y%5 == 0){
string = "gi-oh";
}
if (y%2 == 0 && y%3 == 0 && y%5 == 0){
string = "yu-gi-oh";
}
if (y%2 != 0 && y%3 != 0 && y%5 != 0){
string = y;
};
Array.push(string);
}
console.log(Array);
return true
}
// calling the function
integer(100);
integer(65);
</script>
</html>