Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions assets/js/shapes.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,83 @@
function getLine(length) {
// TODO - write method definition here
let response = "";
for(let i = 0 ; i < length ; i++) {
response += "*";
}
return response;
}



function getBox(width, height) {
// TODO - write method definition here
let response = "";
for(let i = 0 ; i < height ; i++) {
for(let j =0; j < width ; j++) {
response += "*";
}
response += "\n";
}
return response;
}



function getBottomLeftTriangle(length) {
// TODO - write method definition here
let response = "";
for(let i = 1 ; i <= length; i++) {
for(let j = 0 ; j < i; j++) {
response += "*";
}
response += "\n";
}
return response;
}


function getUpperLeftTriangle(length) {
// TODO - write method definition here
let response="";
for (let i = 0 ; i < length ; i++) {
for (let j = i ; j < length ;j++) {
response += "*";
}
response += "\n";
}
return response;
}



function getPyramid(length) {
// TODO - write method definition here
let response="";
for (let i = 1 ; i <= length ; i++) {
for (let j = i ; j < length ; j++) {
response += " ";
}
for( let k = 1; k < (i*2) ; k++) {
response += "*";
}
response += "\n";
}
return response;
}


function getCheckerboard(width, height) {
let response = "";
for (let i = 0; i <height; i++) {
for (let j = 0 ; j < width ; j++) {
if (((i+j)%2) == 0) {
response += " ";
} else {
response += "*";
}
}
response += "\n";
}
return response;
// TODO - write method definition here
}