-
Notifications
You must be signed in to change notification settings - Fork 119
Expand file tree
/
Copy pathscript.js
More file actions
74 lines (73 loc) · 2.47 KB
/
script.js
File metadata and controls
74 lines (73 loc) · 2.47 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
// Please declare functions and variables above where they are used.
// Rings, Center Square, Outline Square, Upside down triangle, Square
var selectedShape = '';
var selectedDimension = 0;
var inputMode = 'Choose';
var outerCounter;
var innerCounter;
var myOutputValue = '';
var main = function (input) {
if (inputMode == 'Choose') {
if (input == 'square' || input == 'triangle' || input == 'upside down triangle') {
selectedShape = input;
myOutputValue = 'hi, you have chosen to draw a ' + selectedShape + '. Please enter dimensions <br>';
inputMode = 'dimension';
} else {
myOutputValue = 'Please input one of the choices: <br>square<br>triangle<br>upside down triangle<br>';
}
} else if (inputMode == 'dimension') {
myOutputValue = '';
if (selectedShape == 'square') {
selectedDimension = input;
outerCounter = 0;
while (outerCounter < selectedDimension) {
innerCounter = 0;
while (innerCounter < selectedDimension) {
myOutputValue = myOutputValue + '👍';
innerCounter = innerCounter + 1;
}
myOutputValue = myOutputValue + '<br>';
outerCounter = outerCounter + 1;
}
} if (selectedShape == 'triangle') {
selectedDimension = input;
outerCounter = 0;
while (outerCounter < selectedDimension) {
innerCounter = -1;
while (innerCounter < outerCounter) {
myOutputValue = myOutputValue + '👍';
innerCounter = innerCounter + 1;
}
myOutputValue = myOutputValue + '<br>';
outerCounter = outerCounter + 1;
}
}
if (selectedShape == 'upside down triangle') {
selectedDimension = input;
outerCounter = selectedDimension;
while (outerCounter != 0) {
innerCounter = 0;
while (innerCounter < outerCounter) {
myOutputValue = myOutputValue + '👍';
innerCounter = innerCounter + 1;
}
myOutputValue = myOutputValue + '<br>';
outerCounter = outerCounter - 1;
}
}
if (selectedShape == 'outline square') {
selectedDimension = input;
outerCounter = 0;
while (outerCounter < selectedDimension) {
innerCounter = 0;
while (innerCounter < selectedDimension) {
myOutputValue = myOutputValue + '👍';
innerCounter = innerCounter + 1;
}
myOutputValue = myOutputValue + '<br>';
outerCounter = outerCounter + 1;
}
}
}
return myOutputValue;
};