From 1961cc3981a3643ea35ea0467a8290a42f69af08 Mon Sep 17 00:00:00 2001 From: Kenrickles Date: Sat, 29 Aug 2020 15:15:32 +0800 Subject: [PATCH] Submission --- package.json | 2 +- script.js | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 70 insertions(+), 2 deletions(-) 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..bafd5d7 100644 --- a/script.js +++ b/script.js @@ -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
'; + inputMode = 'dimension'; + } else { + myOutputValue = 'Please input one of the choices:
square
triangle
upside down triangle
'; + } + } 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 + '
'; + 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 + '
'; + 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 + '
'; + 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 + '
'; + outerCounter = outerCounter + 1; + } + } + } return myOutputValue; };