From 3c8b3ce8816e1a44aaacca4e0e3fe7191d49b76c Mon Sep 17 00:00:00 2001 From: pinnlawjindakul Date: Sat, 29 Aug 2020 11:18:18 +0800 Subject: [PATCH 1/3] square mode based on dimension --- script.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/script.js b/script.js index 0f68729..a3bdefe 100644 --- a/script.js +++ b/script.js @@ -1,6 +1,16 @@ // Please declare functions and variables above where they are used. var main = function (input) { - var myOutputValue = 'hello world'; + 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 From 0c5caf06bb29c779b727ba17f7d169f41c709c8f Mon Sep 17 00:00:00 2001 From: pinnlawjindakul Date: Sat, 29 Aug 2020 12:58:43 +0800 Subject: [PATCH 2/3] added triangle mode and mode status --- script.js | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/script.js b/script.js index a3bdefe..f6430a8 100644 --- a/script.js +++ b/script.js @@ -1,6 +1,40 @@ // Please declare functions and variables above where they are used. +var mode = ""; + var main = function (input) { + 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); + } + 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; +} + +//square mode based on dimension input +var squareMode = function (input) { var myOutputValue = ""; var lineCounter = 0 while (lineCounter < input) { From f215daaa9e282d4e0ab2ad5c58b763ad396c7d0b Mon Sep 17 00:00:00 2001 From: pinnlawjindakul Date: Sat, 29 Aug 2020 13:11:58 +0800 Subject: [PATCH 3/3] added inverted triangle --- script.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/script.js b/script.js index f6430a8..3919795 100644 --- a/script.js +++ b/script.js @@ -11,6 +11,8 @@ var main = function (input) { myOutputValue = triangleMode(input); } else if (mode == "square") { myOutputValue = squareMode(input); + } else if (mode == "inverted") { + myOutputValue = invertedMode(input); } return myOutputValue; }; @@ -33,6 +35,24 @@ var triangleMode = function (input) { 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 = "";