diff --git a/script.js b/script.js index 0f68729..3919795 100644 --- a/script.js +++ b/script.js @@ -1,6 +1,70 @@ // Please declare functions and variables above where they are used. +var mode = ""; + var main = function (input) { - var myOutputValue = 'hello world'; + var myOutputValue = ""; + if (mode == "") { + mode = input; + myOutputValue = "you are in mode: " + mode; + } else if (mode == "triangle") { + myOutputValue = triangleMode(input); + } else if (mode == "square") { + myOutputValue = squareMode(input); + } else if (mode == "inverted") { + myOutputValue = invertedMode(input); + } return myOutputValue; }; + +//triangle mode based on dimension input +var triangleMode = function (input) { + var myOutputValue = ""; + var lineCounter = 0 + while (lineCounter < input) { + var columnCounter = 0; + while (columnCounter < (lineCounter + 1)) { + myOutputValue = myOutputValue + "😀" + console.log("2" + myOutputValue); + columnCounter = columnCounter + 1; + } + myOutputValue = myOutputValue + '
' + console.log("3" + myOutputValue); + lineCounter = lineCounter + 1; + } + return myOutputValue; +} + +//inverted mode based on dimension input +var invertedMode = function (input) { + var myOutputValue = ""; + var lineCounter = 0 + while (lineCounter < input) { + var columnCounter = 0; + while (columnCounter < (input - lineCounter)) { + myOutputValue = myOutputValue + "😀" + console.log("2" + myOutputValue); + columnCounter = columnCounter + 1; + } + myOutputValue = myOutputValue + '
' + console.log("3" + myOutputValue); + lineCounter = lineCounter + 1; + } + return myOutputValue; +} + +//square mode based on dimension input +var squareMode = function (input) { + var myOutputValue = ""; + var lineCounter = 0 + while (lineCounter < input) { + var columnCounter = 0; + while (columnCounter < input) { + myOutputValue = myOutputValue + "😀"; + columnCounter = columnCounter + 1; + } + myOutputValue = myOutputValue + '
'; + lineCounter = lineCounter + 1; + } + return myOutputValue; +} \ No newline at end of file