From e74eb7c0757eb4e612eadf6e78f9eb727e89709f Mon Sep 17 00:00:00 2001 From: ShaneC Date: Sat, 29 Aug 2020 05:29:41 +0800 Subject: [PATCH 1/5] First part done --- script.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/script.js b/script.js index 0f68729..4f3829e 100644 --- a/script.js +++ b/script.js @@ -1,6 +1,18 @@ // Please declare functions and variables above where they are used. var main = function (input) { - var myOutputValue = 'hello world'; + var myOutputValue = ''; + var counter = 0; + while (counter < input) { + // var innerCounter = 0; + // while (innerCounter < input) { + // myOutputValue += '😀'; + // innerCounter += 1; + + counter += 1; + myOutputValue += '😀'; + // myOutputValue += '
'; + } + return myOutputValue; }; From 4df5bf66be0fe296b0f59d2438a49f833513140d Mon Sep 17 00:00:00 2001 From: ShaneC Date: Sat, 29 Aug 2020 05:37:46 +0800 Subject: [PATCH 2/5] square format done --- script.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/script.js b/script.js index 4f3829e..55eaf94 100644 --- a/script.js +++ b/script.js @@ -4,14 +4,13 @@ var main = function (input) { var myOutputValue = ''; var counter = 0; while (counter < input) { - // var innerCounter = 0; - // while (innerCounter < input) { - // myOutputValue += '😀'; - // innerCounter += 1; - + var innerCounter = 0; + while (innerCounter < input) { + myOutputValue += '😀'; + innerCounter += 1; + } counter += 1; - myOutputValue += '😀'; - // myOutputValue += '
'; + myOutputValue += '
'; } return myOutputValue; From b9a241d2756dfe93b09c13148d4cf3b98ee4dc68 Mon Sep 17 00:00:00 2001 From: ShaneC Date: Sat, 29 Aug 2020 05:54:01 +0800 Subject: [PATCH 3/5] Square formed upon input --- script.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script.js b/script.js index 55eaf94..fbc4597 100644 --- a/script.js +++ b/script.js @@ -12,6 +12,6 @@ var main = function (input) { counter += 1; myOutputValue += '
'; } - + // returning output return myOutputValue; }; From bc9907f52f527f2ae24554dc9d757c4d9df76971 Mon Sep 17 00:00:00 2001 From: ShaneC Date: Sat, 29 Aug 2020 05:57:24 +0800 Subject: [PATCH 4/5] Line Formed --- script.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/script.js b/script.js index fbc4597..aeb9075 100644 --- a/script.js +++ b/script.js @@ -4,11 +4,11 @@ var main = function (input) { var myOutputValue = ''; var counter = 0; while (counter < input) { - var innerCounter = 0; - while (innerCounter < input) { - myOutputValue += '😀'; - innerCounter += 1; - } + // var innerCounter = 0; + // while (innerCounter < input) { + // myOutputValue += '😀'; + // innerCounter += 1; + // } counter += 1; myOutputValue += '
'; } From 5abcf9ce1ef9408006e1c4123468036207a46be1 Mon Sep 17 00:00:00 2001 From: ShaneC Date: Sat, 29 Aug 2020 15:02:25 +0800 Subject: [PATCH 5/5] modes implemented --- script.js | 40 +++++++++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/script.js b/script.js index aeb9075..a3fa3b4 100644 --- a/script.js +++ b/script.js @@ -1,16 +1,38 @@ // Please declare functions and variables above where they are used. +var currentGamemode = 'User input shape'; +var shapeChose = ''; var main = function (input) { var myOutputValue = ''; - var counter = 0; - while (counter < input) { - // var innerCounter = 0; - // while (innerCounter < input) { - // myOutputValue += '😀'; - // innerCounter += 1; - // } - counter += 1; - myOutputValue += '
'; + if (currentGamemode == 'User input shape') { + shapeChose = input; + currentGamemode = 'input dimensions'; + } else if (currentGamemode == 'input dimensions') { + if (shapeChose == 'square') { + // draw square + var counter = 0; + while (counter < input) { + var innerCounter = 0; + while (innerCounter < input) { + myOutputValue += '😀'; + innerCounter += 1; + } + counter += 1; + myOutputValue += '
'; + } + } else if (shapeChose == 'triangle') { + // draw triangle + var counter = 0; + while (counter < input) { + var innerCounter = 0; + while (innerCounter <= counter) { + myOutputValue += '😀'; + innerCounter += 1; + } + counter += 1; + myOutputValue += '
'; + } + } } // returning output return myOutputValue;