From 459c8a702ae02fae2e520962e8377f905fba5912 Mon Sep 17 00:00:00 2001 From: suresh kandagatla Date: Mon, 29 Jun 2020 16:56:55 -0400 Subject: [PATCH 1/4] Finished getLine and getBox functions --- assets/js/footer-functions.js | 2 +- assets/js/header-functions.js | 2 +- assets/js/shapes.js | 15 ++++++++++++++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/assets/js/footer-functions.js b/assets/js/footer-functions.js index 42cc05b..a6ff491 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); } function getUpperLeftTriangleTests() { diff --git a/assets/js/header-functions.js b/assets/js/header-functions.js index d17b814..0a0983a 100644 --- a/assets/js/header-functions.js +++ b/assets/js/header-functions.js @@ -21,4 +21,4 @@ function testGetUpperLeftTriangle(expectedOutput, numberOfStars) { function testGetBottomLeftTriangle(expectedOutput, numberOfStars) { test(expectedOutput, getBottomLeftTriangle, numberOfStars); -} \ No newline at end of file +} diff --git a/assets/js/shapes.js b/assets/js/shapes.js index e4351ba..6e46cbf 100644 --- a/assets/js/shapes.js +++ b/assets/js/shapes.js @@ -1,13 +1,26 @@ function getLine(length) { // TODO - write method definition here + var output = ""; + for (var i=0; i Date: Mon, 29 Jun 2020 18:11:16 -0400 Subject: [PATCH 2/4] Added getBottomLeftTriangle and getUpperLeftTriangle functions --- assets/js/shapes.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/assets/js/shapes.js b/assets/js/shapes.js index 6e46cbf..6fc45f8 100644 --- a/assets/js/shapes.js +++ b/assets/js/shapes.js @@ -25,11 +25,25 @@ function getBox(width, height) { function getBottomLeftTriangle(length) { // TODO - write method definition here + var output = ""; + for (var i=1; i <=length; i++){ + for(j=0; ji; j--){ + output+= "*"; + } output = output + "\n"; + + } return output; } From 6d1cbcb762bba29c39c987011a07f3707c1cfe87 Mon Sep 17 00:00:00 2001 From: suresh kandagatla Date: Mon, 29 Jun 2020 22:32:06 -0400 Subject: [PATCH 3/4] Added functions getBottomLeftTriangle, getUpperLeftTriangle and getPyramid with correct output --- assets/js/shapes.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/assets/js/shapes.js b/assets/js/shapes.js index 6fc45f8..7ba27e3 100644 --- a/assets/js/shapes.js +++ b/assets/js/shapes.js @@ -38,7 +38,7 @@ function getBottomLeftTriangle(length) { function getUpperLeftTriangle(length) { // TODO - write method definition here var output = ""; - for (var i=0; i <=length; i++){ + for (var i=0; i i; j--){ output+= "*"; } output = output + "\n"; @@ -50,9 +50,23 @@ function getUpperLeftTriangle(length) { function getPyramid(length) { // TODO - write method definition here + var output = ""; + for(i=1;i <=length; i++){ + for(k=1; k<=length-i; k++){ + output+= " "; + } + for(j=1; j<=i;j++ ){ + for(l=1; l Date: Mon, 29 Jun 2020 23:41:00 -0400 Subject: [PATCH 4/4] Added getCheckerboard (not a perfect solution) --- assets/js/shapes.js | 41 ++++++++++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/assets/js/shapes.js b/assets/js/shapes.js index 7ba27e3..f6564de 100644 --- a/assets/js/shapes.js +++ b/assets/js/shapes.js @@ -51,22 +51,37 @@ function getUpperLeftTriangle(length) { function getPyramid(length) { // TODO - write method definition here var output = ""; - for(i=1;i <=length; i++){ - for(k=1; k<=length-i; k++){ - output+= " "; - } - for(j=1; j<=i;j++ ){ - for(l=1; l