Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion assets/js/footer-functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function getBoxTests() {
function getBottomLeftTriangleTests() {
testGetBottomLeftTriangle("*", 1);
testGetBottomLeftTriangle("*\n**", 2);
testGetBottomLeftTriangle("*\n**\n**", 3);
testGetBottomLeftTriangle("*\n**\n***", 3);
}

function getUpperLeftTriangleTests() {
Expand Down
2 changes: 1 addition & 1 deletion assets/js/header-functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ function testGetUpperLeftTriangle(expectedOutput, numberOfStars) {

function testGetBottomLeftTriangle(expectedOutput, numberOfStars) {
test(expectedOutput, getBottomLeftTriangle, numberOfStars);
}
}
60 changes: 58 additions & 2 deletions assets/js/shapes.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,87 @@
function getLine(length) {
// TODO - write method definition here
var output = "";
for (var i=0; i<length; i++){
output+= "*";
}
return output;
}



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

}



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

}


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

} return output;
}



function getPyramid(length) {
// TODO - write method definition here
var output = "";
for(i=1;i <=length; i++){
for(k=1; k<=length-i; k++){
output+= " ";
}
for(j=1; j<=i;j++ ){
for(l=1; l<j; l++){
output+= "*";
}
output+= "*";

}
output += "\n";
} output += "\n";

return output;
}


function getCheckerboard(width, height) {
// TODO - write method definition here

var output = "";
var check;
for (i=0; i< height; i++){
if(i % 2){
check= "* ";
} else {
check= " *";
}
for(j=0; j< height/2; j++){
output+= check;
}
output+= "\n";
} return output;
}