From 89588e248bc08209ba9c6d1a772e705373fb5193 Mon Sep 17 00:00:00 2001 From: AnjaliG927 Date: Mon, 29 Jun 2020 16:52:00 -0400 Subject: [PATCH 1/2] updated --- assets/js/footer-functions.js | 2 +- assets/js/shapes.js | 44 ++++++++++++++++++++++++++++++----- 2 files changed, 39 insertions(+), 7 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/shapes.js b/assets/js/shapes.js index e4351ba..c740dd1 100644 --- a/assets/js/shapes.js +++ b/assets/js/shapes.js @@ -1,28 +1,60 @@ function getLine(length) { - // TODO - write method definition here + let stars = ""; + for (let iterationCount = 1; iterationCount <= length; iterationCount++) { + stars += "*"; + } + + return stars; } function getBox(width, height) { - // TODO - write method definition here + let stars = ""; + for (let iterationCount = 1; iterationCount <= height; iterationCount++) { + for (let iterationCount = 1; iterationCount <= width; iterationCount++) { + stars += "*"; + } + stars += "\n"; + } + + return stars; } - function getBottomLeftTriangle(length) { - // TODO - write method definition here + let stars = ""; + for (let iterationCount = 1; iterationCount <= length; iterationCount++) { + for (let iterationCount2 = 1; iterationCount2 <= iterationCount; iterationCount2++) { + stars += "*"; + } + stars += "\n"; + } + return stars; } + + function getUpperLeftTriangle(length) { - // TODO - write method definition here + let stars = ""; + for (let iterationCount = length; iterationCount > 0; iterationCount--) { + for (let iterationCount2 = 1; iterationCount2 <= iterationCount; iterationCount2++) { + stars += "*"; + } + stars += "\n"; + } + return stars; } function getPyramid(length) { - // TODO - write method definition here + let stars = ""; + for (let iterationCount = 1; iterationCount <= length; iterationCount++) { + + + } } From 64fdd35f0949857d58296f9ab90730eaeb81a3ee Mon Sep 17 00:00:00 2001 From: AnjaliG927 Date: Tue, 30 Jun 2020 08:54:39 -0400 Subject: [PATCH 2/2] updated pyramid --- assets/js/shapes.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/assets/js/shapes.js b/assets/js/shapes.js index c740dd1..dd4dc9d 100644 --- a/assets/js/shapes.js +++ b/assets/js/shapes.js @@ -51,13 +51,25 @@ function getUpperLeftTriangle(length) { function getPyramid(length) { let stars = ""; - for (let iterationCount = 1; iterationCount <= length; iterationCount++) { - + for (var i = 0; i < length; i++) { + var str = ""; + for (var j = 1; j < length - i; j++) { + str = str + " "; + } + for (var k = 1; k <= (2 * i + 1); k++) { + str = str + "*"; + } + stars += str; + stars += "\n"; } + + return stars; + } + function getCheckerboard(width, height) { - // TODO - write method definition here + }