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
6 changes: 6 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@

<body>
<h1 id="header">SWE101! 🚀</h1>
<center>
<p id="paragraph">1. Choose which shape you'd like to draw<br>Choices include square, triangle and upside down
triangle</p>
<p id="paragraph">2. Choose the dimension by encoding an integer</p>
<p id="paragraph">3. Refresh to start again</p>
</center>
<div id="container">
<input id="my-input" />
<button id="my-button">Submit</button>
Expand Down
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"
}
}
}
73 changes: 72 additions & 1 deletion script.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,77 @@
// Please declare functions and variables above where they are used.
//Mode1 = Shape
//Mode2 = Dimension

var inputMode = 'shape';
var selectedShape = '';
var selectedDimension = 0;

var main = function (input) {
var myOutputValue = 'hello world';
var myOutputValue = '';
var outerCounter;
var innerCounter;

if (inputMode == 'shape') {
selectedShape = input;
myOutputValue = 'hi, you have chosen to draw a ' + selectedShape + '. now enter your preferred dimension <br>';
inputMode = 'dimension';
} else if (inputMode == 'dimension') {
selectedDimension = input;

if (selectedShape == 'square') {
outerCounter = 0;
while (outerCounter < selectedDimension) {
innerCounter = 0;
while (innerCounter < selectedDimension) {
myOutputValue = myOutputValue + '👍';

innerCounter = innerCounter + 1;
}
myOutputValue = myOutputValue + '<br>';
outerCounter = outerCounter + 1;

}
}
if (selectedShape == 'triangle') {
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') {
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') {
outerCounter = 0;
while (outerCounter < selectedDimension) {
innerCounter = 0;
while (innerCounter < selectedDimension) {
myOutputValue = myOutputValue + '👍';

innerCounter = innerCounter + 1;
}
myOutputValue = myOutputValue + '<br>';
outerCounter = outerCounter + 1;

}
}
}
return myOutputValue;
};