Skip to content
Open
6 changes: 3 additions & 3 deletions 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 All @@ -42,7 +42,7 @@ function getPyramidTests() {


function getCheckerboardTests() {
testGetCheckerboard(" *\n* ", 2, 2);
testGetCheckerboard(" * \n* *\n * ", 3, 3);
testGetCheckerboard(" *\n* \n", 2, 2);
testGetCheckerboard(" * \n* *\n * \n", 3, 3);
testGetCheckerboard(" * \n* *\n * \n* *\n", 3, 4);
}
88 changes: 75 additions & 13 deletions assets/js/shapes.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,93 @@
function getLine(length) {
// TODO - write method definition here
}



function getBox(width, height) {
// TODO - write method definition here
//Line
function getLine(length) {

let output = "";
for (let i=0; i<length; i++){
output += "*";
}
return output;
}


//Box
function getBox(width, height) {
let output1 = "";
let output2 = "";

for (let i=0; i<width; i++){
output1 += "*";
}
for (let i=0; i<height; i++){
output2 += output1 + "\n";
}
return output2;
}


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


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



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



//Checkerboard

function getCheckerboard(width, height) {
// TODO - write method definition here
}
let output = "";
for (let i = 0; i <height; i++) {
for (let j = 0 ; j < width ; j++) {
if (((i+j)%2) == 0) {
output += " ";
} else {
output += "*";
}
}
output += "\n";
}
return output;
}
5 changes: 0 additions & 5 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@








<!-- ---------------------------------------------------------------------------------- -->
<!-- ---------------------------------------------------------------------------------- -->
<!-- ---------------------------------------------------------------------------------- -->
Expand Down