From b809dea44009d2a0a9f9b19bc05e86c383b6023a Mon Sep 17 00:00:00 2001 From: Al-Poh Date: Sat, 29 Aug 2020 04:07:18 +0800 Subject: [PATCH] completed till upside down and got BSOD-ed --- script.js | 111 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 110 insertions(+), 1 deletion(-) diff --git a/script.js b/script.js index 0f68729..aab1a67 100644 --- a/script.js +++ b/script.js @@ -1,6 +1,115 @@ // Please declare functions and variables above where they are used. + + +// Setting a counter to limit the amount of times we loop +var gameMode = 'waiting for selection'; +var triangleCounter = 1; +var outerCounter = 0; +var myOutputValue = ''; +var selection = ';' +var upsideDownCounter = 0; + +var main = function (input) { + if (gameMode == 'waiting for selection') { + gameMode = input; + myOutputValue = 'You chose the ' + gameMode + ' game mode.
'; + } else if (gameMode == 'default') { + while (outerCounter < input) { + // Adding a thumbs up emoji to output + myOutputValue = myOutputValue + '👍'; + // Increasing counter by 1 + outerCounter = outerCounter + 1; + } + } else if (gameMode == 'square') { + while (outerCounter < input) { + // declaring inntercounter here is important as we need it's value to reset everytime the function runs + var innerCounter = 0; + + while (innerCounter < input) { + myOutputValue = myOutputValue + '👍'; + innerCounter = innerCounter + 1; + }; + // Adding a
tag after the innerCounter ensures only one
tag per line of emojis + myOutputValue = myOutputValue + '
'; + outerCounter = outerCounter + 1; + }; + } else if (gameMode == 'triangle') { + while (outerCounter < input) { + // Declaring lineCounter here allows us to incrementally add more emojis per line before each
tag + var lineCounter = 0; + while (lineCounter < triangleCounter) { + + myOutputValue = myOutputValue + '👍'; + lineCounter = lineCounter + 1; + }; + triangleCounter = triangleCounter + 1; + outerCounter = outerCounter + 1; + myOutputValue = myOutputValue + '
'; + }; + } else if (gameMode == 'upsidedown') { + var lineCounter = input; + while (outerCounter < input) { + var extraCounter = 0; + while (extraCounter < lineCounter) { + myOutputValue = myOutputValue + '👍'; + extraCounter = extraCounter + 1; + }; + lineCounter = lineCounter - 1; + outerCounter = outerCounter + 1; + myOutputValue = myOutputValue + '
'; + }; + } + + return myOutputValue; +}; + + +// This is the solution for Square +/* var main = function (input) { - var myOutputValue = 'hello world'; + + var outerCounter = 0; + var myOutputValue = ''; + + while (outerCounter < input) { + // declaring inntercounter here is important as we need it's value to reset everytime the function runs + var innerCounter = 0; + + while (innerCounter < input) { + myOutputValue = myOutputValue + '👍'; + innerCounter = innerCounter + 1; + }; + // Adding a
tag after the innerCounter ensures only one
tag per line of emojis + myOutputValue = myOutputValue + '
'; + outerCounter = outerCounter + 1; + }; + return myOutputValue; +}; +*/ + +// This is the solution for Triangle + +/* +var main = function (input) { + // brCounter is the variable to manipulate the number of emojis before each
tag + var brCounter = 1; + var outerCounter = 0; + var myOutputValue = ''; + + while (outerCounter < input) { + // Declaring lineCounter here allows us to incrementally add more emojis per line before each
tag + var lineCounter = 0; + while (lineCounter < brCounter) { + + myOutputValue = myOutputValue + '👍'; + lineCounter = lineCounter + 1; + }; + brCounter = brCounter + 1; + outerCounter = outerCounter + 1; + myOutputValue = myOutputValue + '
'; + }; + return myOutputValue; }; +*/