From 3f8e7441a0a6c7ffd9fde3bcae3a76ccca1d977c Mon Sep 17 00:00:00 2001 From: ANIL CHADDHA Date: Mon, 29 Jun 2020 17:13:32 -0400 Subject: [PATCH 1/5] First Commit --- assets/js/footer-functions.js | 2 +- assets/js/shapes.js | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 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..bfa4d55 100644 --- a/assets/js/shapes.js +++ b/assets/js/shapes.js @@ -1,6 +1,18 @@ function getLine(length) { - // TODO - write method definition here +if(length == 1) +{ + return "*"; +} +else if (length ==2) +{ + return "**"; +} +else { +return "***"; } + +} + From d397bb4379ec19204e59729c5c716054871f0c91 Mon Sep 17 00:00:00 2001 From: ANIL CHADDHA Date: Mon, 29 Jun 2020 21:24:57 -0400 Subject: [PATCH 2/5] Third commit --- assets/js/shapes.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/assets/js/shapes.js b/assets/js/shapes.js index 7e3d79e..70ceefe 100644 --- a/assets/js/shapes.js +++ b/assets/js/shapes.js @@ -30,11 +30,15 @@ function getBox(width, height) { function getBottomLeftTriangle(length) { let output = ""; - for(let i=0;i1){output=output+"\n";} + for(let j=1;j<=i;j++) + { + output+="*"; + } + + } return output; } From 7e4da4ba31e3ccd49f2c9ecbbc28151d04d231af Mon Sep 17 00:00:00 2001 From: ANIL CHADDHA Date: Mon, 29 Jun 2020 21:34:55 -0400 Subject: [PATCH 3/5] Fourth Commit --- assets/js/shapes.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/assets/js/shapes.js b/assets/js/shapes.js index 70ceefe..b0ea56e 100644 --- a/assets/js/shapes.js +++ b/assets/js/shapes.js @@ -46,7 +46,19 @@ function getBottomLeftTriangle(length) { function getUpperLeftTriangle(length) { - // TODO - write method definition here + + let output = ""; + for(let i=1;i<=length;i++) + { + if(i>1){output=output+"\n";} + for(let j=length;j>=i;j--) + { + output+="*"; + } + + } + return output; + } From 6e46f4905d0f8e1a9a62c89160dbeec21ab07818 Mon Sep 17 00:00:00 2001 From: ANIL CHADDHA Date: Sun, 5 Jul 2020 14:20:05 -0400 Subject: [PATCH 4/5] Pyramid added --- assets/js/shapes.js | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/assets/js/shapes.js b/assets/js/shapes.js index b0ea56e..2239384 100644 --- a/assets/js/shapes.js +++ b/assets/js/shapes.js @@ -64,10 +64,30 @@ function getUpperLeftTriangle(length) { function getPyramid(length) { - // TODO - write method definition here + let output = ""; + for(let i=1;i<=length;i++) + { + if (i >1) {output +="\n";} + //let output = ''; + for(let j=1; j<=(2*length-1);j++){ + + (j>=length+1-i && j<=length-1+i) ? output +="*" : output += " "; + } + } + return output; } function getCheckerboard(width, height) { - // TODO - write method definition here + let output = ""; + for(let i=1;i<=width;i++) + { + if (i >1) output +="\n"; + //let output = ''; + for(let j=1; j<=height;j++){ + + (j>=width+1-i && j<=height-1+i) ? output +="*" : output += " "; + } + } + return output; } From dbf404c5bf38ba652696b715032cd6cb2958fdc3 Mon Sep 17 00:00:00 2001 From: ANIL CHADDHA Date: Sun, 5 Jul 2020 14:32:28 -0400 Subject: [PATCH 5/5] Checker Board tried --- assets/js/shapes.js | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/assets/js/shapes.js b/assets/js/shapes.js index 2239384..6d37b38 100644 --- a/assets/js/shapes.js +++ b/assets/js/shapes.js @@ -80,14 +80,24 @@ function getPyramid(length) { function getCheckerboard(width, height) { let output = ""; - for(let i=1;i<=width;i++) - { - if (i >1) output +="\n"; - //let output = ''; - for(let j=1; j<=height;j++){ - - (j>=width+1-i && j<=height-1+i) ? output +="*" : output += " "; - } - } + let row = 0; + let col = 0; + + while(row<=width){ + flag = row%2; + while(col<=height){ + if(flag){ + output+= "* "; + } + else{ + output+= " *"; + } + col++; + } + output+="\n"; + col=0; + row++; + + } return output; }