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); //test is fubar, added the missing *
}

function getUpperLeftTriangleTests() {
Expand Down
51 changes: 51 additions & 0 deletions assets/js/shapes.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,73 @@
function getLine(length) {
// TODO - write method definition here
var answer = "";
for(let x = 1; x <= length; x++){
answer += "*";
}
return answer;
}



function getBox(width, height) {
// TODO - write method definition here
var answer = "";
for(let x = 1; x <= height; x++){
for(let y = 1; y <= width; y++){
answer += "*";
}
answer += "\n";
}
return answer;
}



function getBottomLeftTriangle(length) {
// TODO - write method definition here
var answer = "";
var loop = true;
var count = 1;
do{
//Create current line
for(let x = 1; x <= count; x++){
answer += "*";
}
//Add new line if
if(count != length){
answer += "\n";
}
//Increment my counter
count ++;
if(count > length){
loop = false;
}
}while(loop);
return answer;
}


function getUpperLeftTriangle(length) {
// TODO - write method definition here
var answer = "";
var loop = true;
var count = length;
do{
//Create current line
for(let x = 1; x <= count; x++){
answer += "*";
}
//Add new line if
if(count != 1){
answer += "\n";
}
//Decrement my counter
count --;
if(count === 0){
loop = false;
}
}while(loop);
return answer;
}


Expand Down