From 2a2ab3c667bbd68b18df074779135e966a1d698d Mon Sep 17 00:00:00 2001 From: Ezra Vance <3zravance@gmail.com> Date: Mon, 29 Jun 2020 16:55:47 -0400 Subject: [PATCH 1/7] still working it all out in my head. --- assets/js/shapes.js | 1 + 1 file changed, 1 insertion(+) diff --git a/assets/js/shapes.js b/assets/js/shapes.js index e4351ba..0ad8e6c 100644 --- a/assets/js/shapes.js +++ b/assets/js/shapes.js @@ -1,5 +1,6 @@ function getLine(length) { // TODO - write method definition here + console.log(length); } From 18beb8fc78e295e2e667077d60dbfe6f89a7ccc0 Mon Sep 17 00:00:00 2001 From: Ezra Vance <3zravance@gmail.com> Date: Mon, 29 Jun 2020 16:56:42 -0400 Subject: [PATCH 2/7] for loop setup --- assets/js/footer-functions.js | 2 +- assets/js/shapes.js | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/assets/js/footer-functions.js b/assets/js/footer-functions.js index 42cc05b..b187a40 100644 --- a/assets/js/footer-functions.js +++ b/assets/js/footer-functions.js @@ -24,7 +24,7 @@ function getBoxTests() { function getBottomLeftTriangleTests() { testGetBottomLeftTriangle("*", 1); testGetBottomLeftTriangle("*\n**", 2); - testGetBottomLeftTriangle("*\n**\n**", 3); + testGetBottomLeftTriangle("*\n**\n***", 3); //test is fubar, added the missing * } function getUpperLeftTriangleTests() { diff --git a/assets/js/shapes.js b/assets/js/shapes.js index 0ad8e6c..00a6b0b 100644 --- a/assets/js/shapes.js +++ b/assets/js/shapes.js @@ -1,6 +1,8 @@ function getLine(length) { // TODO - write method definition here - console.log(length); + for(let x = 1; x <= legnth; x++){ + //do the thing + } } From 03c1c1087c94bc6aefb0304c32ef5ec37bc0946c Mon Sep 17 00:00:00 2001 From: Ezra Vance <3zravance@gmail.com> Date: Mon, 29 Jun 2020 17:02:40 -0400 Subject: [PATCH 3/7] getLine tests passed. --- assets/js/shapes.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/assets/js/shapes.js b/assets/js/shapes.js index 00a6b0b..97a5886 100644 --- a/assets/js/shapes.js +++ b/assets/js/shapes.js @@ -1,8 +1,11 @@ function getLine(length) { // TODO - write method definition here - for(let x = 1; x <= legnth; x++){ - //do the thing + var answer = ""; + var userIn = length; + for(let x = 1; x <= userIn; x++){ + answer += "*"; } + return answer; } From 4116be708ec6ef5ea377e9cb652062b2a8cf2f7f Mon Sep 17 00:00:00 2001 From: Ezra Vance <3zravance@gmail.com> Date: Mon, 29 Jun 2020 17:08:33 -0400 Subject: [PATCH 4/7] getBox tests passed. --- assets/js/shapes.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/assets/js/shapes.js b/assets/js/shapes.js index 97a5886..f7c6da3 100644 --- a/assets/js/shapes.js +++ b/assets/js/shapes.js @@ -12,6 +12,16 @@ function getLine(length) { function getBox(width, height) { // TODO - write method definition here + var answer = ""; + var userIn1 = width; + var userIn2 = height; + for(let x = 1; x <= height; x++){ + for(let y = 1; y <= width; y++){ + answer += "*"; + } + answer += "\n"; + } + return answer; } From 996c8a6a8c7eae8d3eca77eaef99b3f5231f3123 Mon Sep 17 00:00:00 2001 From: Ezra Vance <3zravance@gmail.com> Date: Mon, 29 Jun 2020 17:10:29 -0400 Subject: [PATCH 5/7] removed those userIn vars I had. --- assets/js/shapes.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/assets/js/shapes.js b/assets/js/shapes.js index f7c6da3..7192596 100644 --- a/assets/js/shapes.js +++ b/assets/js/shapes.js @@ -1,8 +1,7 @@ function getLine(length) { // TODO - write method definition here var answer = ""; - var userIn = length; - for(let x = 1; x <= userIn; x++){ + for(let x = 1; x <= length; x++){ answer += "*"; } return answer; @@ -13,8 +12,6 @@ function getLine(length) { function getBox(width, height) { // TODO - write method definition here var answer = ""; - var userIn1 = width; - var userIn2 = height; for(let x = 1; x <= height; x++){ for(let y = 1; y <= width; y++){ answer += "*"; From c6d5117c8240e1fbdb8b1a1b5512e48d65eb2b17 Mon Sep 17 00:00:00 2001 From: Ezra Vance <3zravance@gmail.com> Date: Mon, 29 Jun 2020 18:16:53 -0400 Subject: [PATCH 6/7] getBottemLeftTriangle tests passed. --- assets/js/shapes.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/assets/js/shapes.js b/assets/js/shapes.js index 7192596..7cea203 100644 --- a/assets/js/shapes.js +++ b/assets/js/shapes.js @@ -25,6 +25,25 @@ function getBox(width, height) { function getBottomLeftTriangle(length) { // TODO - write method definition here + var answer = ""; + var loop = true; + var count = 1; + do{ + //Create current line + for(let x = 1; x <= count; x++){ + answer += "*"; + } + //Add new line if + if(count != length){ + answer += "\n"; + } + //Increment my counter + count ++; + if(count > length){ + loop = false; + } + }while(loop); + return answer; } From 85b1e6b88b0d5fe87ca1fa74c8783cc60a842d42 Mon Sep 17 00:00:00 2001 From: Ezra Vance <3zravance@gmail.com> Date: Mon, 29 Jun 2020 18:25:22 -0400 Subject: [PATCH 7/7] getUppderLeftTriangle tests passed. --- assets/js/shapes.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/assets/js/shapes.js b/assets/js/shapes.js index 7cea203..b2b2554 100644 --- a/assets/js/shapes.js +++ b/assets/js/shapes.js @@ -49,6 +49,25 @@ function getBottomLeftTriangle(length) { function getUpperLeftTriangle(length) { // TODO - write method definition here + var answer = ""; + var loop = true; + var count = length; + do{ + //Create current line + for(let x = 1; x <= count; x++){ + answer += "*"; + } + //Add new line if + if(count != 1){ + answer += "\n"; + } + //Decrement my counter + count --; + if(count === 0){ + loop = false; + } + }while(loop); + return answer; }