From 430cf13b279c2abe9ec5d736a2381b8f20eda861 Mon Sep 17 00:00:00 2001 From: razeroual <47251928+razeroual@users.noreply.github.com> Date: Mon, 29 Jun 2020 16:58:36 -0400 Subject: [PATCH 1/3] update --- assets/css/style.css | 2 +- assets/js/footer-functions.js | 6 +++--- assets/js/shapes.js | 40 +++++++++++++++++++++++++++-------- 3 files changed, 35 insertions(+), 13 deletions(-) diff --git a/assets/css/style.css b/assets/css/style.css index 740b9a3..aedca28 100644 --- a/assets/css/style.css +++ b/assets/css/style.css @@ -1,5 +1,5 @@ body { - background-color: navy; + background-color: rgb(171, 171, 218); color: white; } diff --git a/assets/js/footer-functions.js b/assets/js/footer-functions.js index 42cc05b..af69436 100644 --- a/assets/js/footer-functions.js +++ b/assets/js/footer-functions.js @@ -22,9 +22,9 @@ function getBoxTests() { } function getBottomLeftTriangleTests() { - testGetBottomLeftTriangle("*", 1); - testGetBottomLeftTriangle("*\n**", 2); - testGetBottomLeftTriangle("*\n**\n**", 3); + testGetBottomLeftTriangle("*\n", 1); + testGetBottomLeftTriangle("*\n**\n", 2); + testGetBottomLeftTriangle("*\n**\n***\n", 3); } function getUpperLeftTriangleTests() { diff --git a/assets/js/shapes.js b/assets/js/shapes.js index e4351ba..05dbb8e 100644 --- a/assets/js/shapes.js +++ b/assets/js/shapes.js @@ -1,22 +1,44 @@ function getLine(length) { - // TODO - write method definition here -} + let lineExpected= ""; + for(let loopCounter = 0; loopCounter < length; loopCounter++){ + lineExpected = lineExpected + "*"; + } + return lineExpected; +} function getBox(width, height) { - // TODO - write method definition here + let lineExpected= ""; + for(let lineLoopCounter = 0; lineLoopCounter < width; lineLoopCounter++){ + for(let culLoopCounter = 0; culLoopCounter < height; culLoopCounter++){ + lineExpected = lineExpected + "*"; + } + lineExpected = lineExpected + "\n"; + } + return lineExpected; } - - function getBottomLeftTriangle(length) { - // TODO - write method definition here + let lineExpected= ""; + for(let lineLoopCounter = 0; lineLoopCounter < length; lineLoopCounter++){ + for(let culLoopCounter = 0; culLoopCounter < lineLoopCounter; culLoopCounter++){ + lineExpected = lineExpected + "*"; + } + lineExpected = lineExpected + "\n"; + } + return lineExpected; } - function getUpperLeftTriangle(length) { - // TODO - write method definition here + let lineExpected= ""; + for(let lineLoopCounter = 0; lineLoopCounter < length; lineLoopCounter++){ + for(let culLoopCounter = 0; culLoopCounter < lineLoopCounter; culLoopCounter++){ + lineExpected = lineExpected + "*"; + } + lineExpected = lineExpected + "\n"; + } + return lineExpected; } @@ -28,4 +50,4 @@ function getPyramid(length) { function getCheckerboard(width, height) { // TODO - write method definition here -} +} \ No newline at end of file From 30689a5e289b467e546267af3f47bb5b46d07a3b Mon Sep 17 00:00:00 2001 From: razeroual <47251928+razeroual@users.noreply.github.com> Date: Tue, 30 Jun 2020 00:51:59 -0400 Subject: [PATCH 2/3] update --- assets/js/shapes.js | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/assets/js/shapes.js b/assets/js/shapes.js index 05dbb8e..a9a5734 100644 --- a/assets/js/shapes.js +++ b/assets/js/shapes.js @@ -21,7 +21,7 @@ function getBox(width, height) { function getBottomLeftTriangle(length) { let lineExpected= ""; - for(let lineLoopCounter = 0; lineLoopCounter < length; lineLoopCounter++){ + for(let lineLoopCounter = 0; lineLoopCounter <= length; lineLoopCounter++){ for(let culLoopCounter = 0; culLoopCounter < lineLoopCounter; culLoopCounter++){ lineExpected = lineExpected + "*"; } @@ -32,8 +32,8 @@ function getBottomLeftTriangle(length) { function getUpperLeftTriangle(length) { let lineExpected= ""; - for(let lineLoopCounter = 0; lineLoopCounter < length; lineLoopCounter++){ - for(let culLoopCounter = 0; culLoopCounter < lineLoopCounter; culLoopCounter++){ + for(let lineLoopCounter = length; lineLoopCounter >= 0; lineLoopCounter--){ + for(let culLoopCounter = lineLoopCounter ; culLoopCounter > 0; culLoopCounter--){ lineExpected = lineExpected + "*"; } lineExpected = lineExpected + "\n"; @@ -41,13 +41,27 @@ function getUpperLeftTriangle(length) { return lineExpected; } - - function getPyramid(length) { - // TODO - write method definition here + let lineExpected= ""; + for(let lineLoopCounter = 0; lineLoopCounter <= length; lineLoopCounter++){ + if (lineLoopCounter %2 != 0){ + for(let culLoopCounter = 0; culLoopCounter < lineLoopCounter; culLoopCounter++){ + lineExpected = lineExpected + "*"; + } + } + lineExpected = lineExpected + "\n"; + } + return lineExpected; } function getCheckerboard(width, height) { - // TODO - write method definition here + let lineExpected= ""; + for(let lineLoopCounter = 0; lineLoopCounter < width; lineLoopCounter++){ + for(let culLoopCounter = 0; culLoopCounter < height; culLoopCounter++){ + lineExpected = lineExpected + "*"; + } + lineExpected = lineExpected + "\n"; + } + return lineExpected; } \ No newline at end of file From dde2e78fae881c1fb72061e0b0abe43063ce2edd Mon Sep 17 00:00:00 2001 From: razeroual <47251928+razeroual@users.noreply.github.com> Date: Tue, 30 Jun 2020 01:29:10 -0400 Subject: [PATCH 3/3] update --- assets/js/shapes.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/assets/js/shapes.js b/assets/js/shapes.js index a9a5734..d9fe7d9 100644 --- a/assets/js/shapes.js +++ b/assets/js/shapes.js @@ -56,10 +56,16 @@ function getPyramid(length) { function getCheckerboard(width, height) { - let lineExpected= ""; + let lineExpected= "_"; for(let lineLoopCounter = 0; lineLoopCounter < width; lineLoopCounter++){ for(let culLoopCounter = 0; culLoopCounter < height; culLoopCounter++){ - lineExpected = lineExpected + "*"; + i = lineExpected.charAt(myString.length - 1) + if (i == "\n") + lineExpected.charAt(myString.length - 2) + if(i == "*") + lineExpected = lineExpected + "_"; + else + lineExpected = lineExpected + "*"; } lineExpected = lineExpected + "\n"; }