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
83 changes: 79 additions & 4 deletions assets/js/shapes.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,106 @@
function getLine(length) {
// TODO - write method definition here
//length= prompt("Please Enter desired line length");
if(length==1){
return "*";
}else if(length==2){
return "**";
}else return "***";
}



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




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




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



function getPyramid(length) {
// TODO - write method definition here
}

let output= "";
for(let i = 0; i <= length; i++){
if (i %2 != 0){
for(let j = 0; j < i; j){
output = output + "*";
}
}
output = output + "\n";
}
return output;
}




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

}
return output;
}