From 07c29a4cb46228e00894ce51bdefcb956130be85 Mon Sep 17 00:00:00 2001 From: Laura Godinez Date: Mon, 29 Jun 2020 16:55:29 -0400 Subject: [PATCH 1/3] Edits made during class --- assets/js/footer-functions.js | 44 +++++++++++++----------------- assets/js/shapes.js | 50 +++++++++++++++++++++++++---------- 2 files changed, 55 insertions(+), 39 deletions(-) diff --git a/assets/js/footer-functions.js b/assets/js/footer-functions.js index 42cc05b..e1a4f24 100644 --- a/assets/js/footer-functions.js +++ b/assets/js/footer-functions.js @@ -5,44 +5,38 @@ getUpperLeftTriangleTests(); getPyramidTests(); getCheckerboardTests(); - - - function getLineTests() { - testGetLine("*", 1); - testGetLine("**", 2); - testGetLine("***", 3); + testGetLine("*", 1); + testGetLine("**", 2); + testGetLine("***", 3); } - function getBoxTests() { - testGetBox("*\n", 1, 1); - testGetBox("**\n**\n", 2, 2); - testGetBox("***\n***\n***\n***\n", 3, 4); + testGetBox("*\n", 1, 1); + testGetBox("**\n**\n", 2, 2); + testGetBox("***\n***\n***\n***\n", 3, 4); } function getBottomLeftTriangleTests() { - testGetBottomLeftTriangle("*", 1); - testGetBottomLeftTriangle("*\n**", 2); - testGetBottomLeftTriangle("*\n**\n**", 3); + testGetBottomLeftTriangle("*", 1); + testGetBottomLeftTriangle("*\n**", 2); + testGetBottomLeftTriangle("*\n**\n**", 3); } function getUpperLeftTriangleTests() { - testGetUpperLeftTriangle("*", 1); - testGetUpperLeftTriangle("**\n*", 2); - testGetUpperLeftTriangle("***\n**\n*", 3); + testGetUpperLeftTriangle("*", 1); + testGetUpperLeftTriangle("**\n*", 2); + testGetUpperLeftTriangle("***\n**\n*", 3); } - function getPyramidTests() { - testGetPyramid("*", 1); - testGetPyramid(" * \n***", 2); - testGetPyramid(" * \n *** \n*****", 3); + testGetPyramid("*", 1); + testGetPyramid(" * \n***", 2); + testGetPyramid(" * \n *** \n*****", 3); } - function getCheckerboardTests() { - testGetCheckerboard(" *\n* ", 2, 2); - testGetCheckerboard(" * \n* *\n * ", 3, 3); - testGetCheckerboard(" * \n* *\n * \n* *\n", 3, 4); -} \ No newline at end of file + testGetCheckerboard(" *\n* ", 2, 2); + testGetCheckerboard(" * \n* *\n * ", 3, 3); + testGetCheckerboard(" * \n* *\n * \n* *\n", 3, 4); +} diff --git a/assets/js/shapes.js b/assets/js/shapes.js index e4351ba..e9b0477 100644 --- a/assets/js/shapes.js +++ b/assets/js/shapes.js @@ -1,31 +1,53 @@ function getLine(length) { - // TODO - write method definition here + let output = ""; + let iterationCounter = 0; + for (iterationCounter; iterationCounter < length; iterationCounter++) { + output += "*"; + } + return output; } - - function getBox(width, height) { - // TODO - write method definition here + let output = ""; + let iterationCounter; + let iterationCounter_2; + + for (iterationCounter = 0; iterationCounter < height; iterationCounter++) { + for ( + iterationCounter_2 = 0; + iterationCounter_2 < width; + iterationCounter_2++ + ) { + output += "*"; + } + output += "\n"; + } + return output; } - - function getBottomLeftTriangle(length) { - // TODO - write method definition here + let iterationCounter; + let iterationCounter_2; + for (iterationCounter = 0; iterationCounter < length; iterationCounter++) { + for ( + iterationCounter_2 = 0; + iterationCounter_2 < iterationCounter; + iterationCounter_2 + ) { + output += "*"; + } + output += "br/>"; + } } - function getUpperLeftTriangle(length) { - // TODO - write method definition here + // TODO - write method definition here } - - function getPyramid(length) { - // TODO - write method definition here + // TODO - write method definition here } - function getCheckerboard(width, height) { - // TODO - write method definition here + // TODO - write method definition here } From 7155b17b0840d6a26c44cd85d0a3359f8e58bf35 Mon Sep 17 00:00:00 2001 From: Laura Godinez Date: Mon, 29 Jun 2020 23:20:31 -0400 Subject: [PATCH 2/3] First few js edits --- assets/js/footer-functions.js | 16 ++++++++-------- assets/js/shapes.js | 25 +++++++++++++++++++++---- 2 files changed, 29 insertions(+), 12 deletions(-) diff --git a/assets/js/footer-functions.js b/assets/js/footer-functions.js index e1a4f24..ea4906e 100644 --- a/assets/js/footer-functions.js +++ b/assets/js/footer-functions.js @@ -18,15 +18,15 @@ 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() { - testGetUpperLeftTriangle("*", 1); - testGetUpperLeftTriangle("**\n*", 2); - testGetUpperLeftTriangle("***\n**\n*", 3); + testGetUpperLeftTriangle("*\n", 1); + testGetUpperLeftTriangle("**\n*\n", 2); + testGetUpperLeftTriangle("***\n**\n*\n", 3); } function getPyramidTests() { @@ -36,7 +36,7 @@ function getPyramidTests() { } function getCheckerboardTests() { - testGetCheckerboard(" *\n* ", 2, 2); - testGetCheckerboard(" * \n* *\n * ", 3, 3); + testGetCheckerboard(" *\n* \n", 2, 2); + testGetCheckerboard(" * \n* *\n *\n ", 3, 3); testGetCheckerboard(" * \n* *\n * \n* *\n", 3, 4); } diff --git a/assets/js/shapes.js b/assets/js/shapes.js index e9b0477..5a97dad 100644 --- a/assets/js/shapes.js +++ b/assets/js/shapes.js @@ -28,20 +28,37 @@ function getBox(width, height) { function getBottomLeftTriangle(length) { let iterationCounter; let iterationCounter_2; - for (iterationCounter = 0; iterationCounter < length; iterationCounter++) { + let output = ""; + for (iterationCounter = 1; iterationCounter <= length; iterationCounter++) { for ( iterationCounter_2 = 0; iterationCounter_2 < iterationCounter; - iterationCounter_2 + iterationCounter_2++ ) { output += "*"; } - output += "br/>"; + output += "\n"; } + return output; } function getUpperLeftTriangle(length) { - // TODO - write method definition here + let output = ""; + let iterationCounter; + let iterationCounter_2; + + for (iterationCounter = length; iterationCounter >= 1; iterationCounter--) { + for ( + iterationCounter_2 = length - 1; + iterationCounter_2 >= length - iterationCounter; + iterationCounter_2-- + ) { + output += "*"; + } + + output += "\n"; + } + return output; } function getPyramid(length) { From 57c26444e542bf1b8a370cf1db1a84a42210bbdb Mon Sep 17 00:00:00 2001 From: Laura Godinez Date: Tue, 30 Jun 2020 08:57:45 -0400 Subject: [PATCH 3/3] edits --- assets/js/shapes.js | 43 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/assets/js/shapes.js b/assets/js/shapes.js index 5a97dad..445e462 100644 --- a/assets/js/shapes.js +++ b/assets/js/shapes.js @@ -62,9 +62,48 @@ function getUpperLeftTriangle(length) { } function getPyramid(length) { - // TODO - write method definition here + let shape=""; + let iterationCounter; + let iterationCounter_2; + let iteration_Counter_3; + let line; + if (length ==0 || length==1) return getLine(length); + for (iterationCounter=1; iterationCounter<=length;iterationCounter++){ + line = ""; + for (iterationCounter_2=1 ;iterationCounter_2<=length;iterationCounter_2++){ + line +=" "; + + } + for (iteration_Counter_3=1;iteration_Counter_3<=iterationCounter+2; iteration_Counter_3++{ + line+="*"; + shape+= line + "\n"; + } + } + return shape; } + + function getCheckerboard(width, height) { - // TODO - write method definition here + let output=""; + + let iterationCounter; + let iterationCounter_2; + let iteration_Counter_3=1; + + for( iterationCounter = 1; iterationCounter <= height; iterationCounter++) { + for(iterationCounter_2 = width; iterationCounter_2 > 0; iterationCounter_2--) { + if(iteration_Counter_3 % 2 == 0) { + output += "*"; + } + else { + output += " "; + } + iteration_Counter_3++; + } + if(width % 2 == 0) { iteration_Counter_3++; } + output += "\n"; + } + return output; + }