Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@
"eslint-config-airbnb-base": "^14.2.0",
"eslint-plugin-import": "^2.22.0"
}
}
}
70 changes: 69 additions & 1 deletion script.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,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) {
var myOutputValue = 'hello world';
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;
};