-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
122 lines (106 loc) · 2.58 KB
/
script.js
File metadata and controls
122 lines (106 loc) · 2.58 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
" use strict ";
var display = document.getElementById("display");
function yourFunctionName (){
display.innerHTML = "hello";
}
function oneToTen (){
var output = "oneToTen()<br>";
output = output + "***Output***<br>";
for (var i=1; i<=10; i++){
output = output + i + "<br>";
}
display.innerHTML = output;
}
function oddNumbers (){
var output = "oddNumbers()<br>";
output = output + "***Output***<br>";
for (var i=1; i<=20; i++){
if(i % 2 === 1){
output = output + i + "<br>";
}
}
display.innerHTML = output;
}
function squares(){
var output = "squares()<br>";
output = output + "***Output***<br>";
for (var i=1; i<=10; i++){
output = output + Math.pow(i,2) + "<br>";
}
display.innerHTML = output;
}
function random4(){
var output = "random4()<br>";
output = output + "***Output***<br>";
for (var i=1; i<=4; i++){
output = output + Math.floor(Math.random()*10) + "<br>";
}
display.innerHTML = output;
}
function even (){
var output = "even(20)<br>";
output = output + "***Output***<br>";
for (var i=1; i<20; i++){
if(i % 2 == 0){
output = output + i + "<br>";
}
}
display.innerHTML = output;
}
function powers(){
var output = "powers(8)<br>";
output = output + "***Output***<br>";
for (var i=1; i<=8; i++){
output = output + Math.pow(2,i) + "<br>";
}
display.innerHTML = output;
}
function areWeThereYet (){
var output = "Arewethereyet?<br>";
do{
var yesOrNo = prompt("Are we there yet?");
output = output + yesOrNo + "<br>";
if (yesOrNo === "Yes"){
output = output + "Good!<br>";
}
else if (yesOrNo != null){
output = output + "Arewethereyet?<br>";
}
}while(yesOrNo !== "Yes");
display.innerHTML = output;
}
function triangle(){
var output = "triangle()<br>";
output = output + "***Output***<br>";
for (var i=1;i<=5;i++){
for(var j=1; j<=i; j++){
output = output + "* ";
}
output = output + "<br>";
}
display.innerHTML = output;
}
function tableSquare(){
var output = "tableSquare()<br>";
output = output + "***Output***<br>";
output = output + "A4x4tablesquare<br>";
for (var i=1;i<=4;i++){
for(var j=1; j<=4; j++){
output = output + "|" + j*i;
}
output = output + "|<br>";
}
display.innerHTML = output;
}
function tableSquares(){
var output = "tableSquares(6)<br>";
output = output + "***Output***<br>";
output = output + "A6x6tablesquare<br>";
for (var i=1;i<=6;i++){
for(var j=1; j<=6; j++){
output = output + "|" + j*i;
}
output = output + "|<br>";
}
display.innerHTML = output;
}