diff --git a/assets/js/shapes.js b/assets/js/shapes.js index e4351ba..6d37b38 100644 --- a/assets/js/shapes.js +++ b/assets/js/shapes.js @@ -1,31 +1,103 @@ function getLine(length) { - // TODO - write method definition here + let output = ""; + for(let i=0;i1){output=output+"\n";} + for(let j=1;j<=i;j++) + { + output+="*"; + } + + } + return output; } + + 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; + } 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 = ""; + 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; }