diff --git a/index.html b/index.html index cb17c82..cff1345 100644 --- a/index.html +++ b/index.html @@ -40,6 +40,12 @@

SWE101! 🚀

+
+

1. Choose which shape you'd like to draw
Choices include square, triangle and upside down + triangle

+

2. Choose the dimension by encoding an integer

+

3. Refresh to start again

+
diff --git a/package.json b/package.json index 90af81e..da8bab3 100644 --- a/package.json +++ b/package.json @@ -21,4 +21,4 @@ "eslint-config-airbnb-base": "^14.2.0", "eslint-plugin-import": "^2.22.0" } -} \ No newline at end of file +} diff --git a/script.js b/script.js index 0f68729..19469b3 100644 --- a/script.js +++ b/script.js @@ -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
'; + 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 + '
'; + outerCounter = outerCounter + 1; + + } + } + if (selectedShape == 'triangle') { + outerCounter = 0; + while (outerCounter < selectedDimension) { + innerCounter = -1; + while (innerCounter < outerCounter) { + myOutputValue = myOutputValue + '👍'; + + innerCounter = innerCounter + 1; + } + myOutputValue = myOutputValue + '
'; + 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 + '
'; + outerCounter = outerCounter - 1; + } + } + if (selectedShape == 'outline square') { + outerCounter = 0; + while (outerCounter < selectedDimension) { + innerCounter = 0; + while (innerCounter < selectedDimension) { + myOutputValue = myOutputValue + '👍'; + + innerCounter = innerCounter + 1; + } + myOutputValue = myOutputValue + '
'; + outerCounter = outerCounter + 1; + + } + } + } return myOutputValue; };