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
44 changes: 19 additions & 25 deletions assets/js/footer-functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,44 +5,38 @@ getUpperLeftTriangleTests();
getPyramidTests();
getCheckerboardTests();




function getLineTests() {
testGetLine("*", 1);
testGetLine("**", 2);
testGetLine("***", 3);
testGetLine("*", 1);
testGetLine("**", 2);
testGetLine("***", 3);
}


function getBoxTests() {
testGetBox("*\n", 1, 1);
testGetBox("**\n**\n", 2, 2);
testGetBox("***\n***\n***\n***\n", 3, 4);
testGetBox("*\n", 1, 1);
testGetBox("**\n**\n", 2, 2);
testGetBox("***\n***\n***\n***\n", 3, 4);
}

function getBottomLeftTriangleTests() {
testGetBottomLeftTriangle("*", 1);
testGetBottomLeftTriangle("*\n**", 2);
testGetBottomLeftTriangle("*\n**\n**", 3);
testGetBottomLeftTriangle("*\n", 1);
testGetBottomLeftTriangle("*\n**\n", 2);
testGetBottomLeftTriangle("*\n**\n***\n", 3);
}

function getUpperLeftTriangleTests() {
testGetUpperLeftTriangle("*", 1);
testGetUpperLeftTriangle("**\n*", 2);
testGetUpperLeftTriangle("***\n**\n*", 3);
testGetUpperLeftTriangle("*\n", 1);
testGetUpperLeftTriangle("**\n*\n", 2);
testGetUpperLeftTriangle("***\n**\n*\n", 3);
}


function getPyramidTests() {
testGetPyramid("*", 1);
testGetPyramid(" * \n***", 2);
testGetPyramid(" * \n *** \n*****", 3);
testGetPyramid("*", 1);
testGetPyramid(" * \n***", 2);
testGetPyramid(" * \n *** \n*****", 3);
}


function getCheckerboardTests() {
testGetCheckerboard(" *\n* ", 2, 2);
testGetCheckerboard(" * \n* *\n * ", 3, 3);
testGetCheckerboard(" * \n* *\n * \n* *\n", 3, 4);
}
testGetCheckerboard(" *\n* \n", 2, 2);
testGetCheckerboard(" * \n* *\n *\n ", 3, 3);
testGetCheckerboard(" * \n* *\n * \n* *\n", 3, 4);
}
102 changes: 90 additions & 12 deletions assets/js/shapes.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,109 @@
function getLine(length) {
// TODO - write method definition here
let output = "";
let iterationCounter = 0;
for (iterationCounter; iterationCounter < length; iterationCounter++) {
output += "*";
}
return output;
}



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

let output = "";
let iterationCounter;
let iterationCounter_2;

for (iterationCounter = 0; iterationCounter < height; iterationCounter++) {
for (
iterationCounter_2 = 0;
iterationCounter_2 < width;
iterationCounter_2++
) {
output += "*";
}
output += "\n";
}
return output;
}

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


function getUpperLeftTriangle(length) {
// TODO - write method definition here
}
let output = "";
let iterationCounter;
let iterationCounter_2;

for (iterationCounter = length; iterationCounter >= 1; iterationCounter--) {
for (
iterationCounter_2 = length - 1;
iterationCounter_2 >= length - iterationCounter;
iterationCounter_2--
) {
output += "*";
}

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

function getPyramid(length) {
// TODO - write method definition here
let shape="";
let iterationCounter;
let iterationCounter_2;
let iteration_Counter_3;
let line;
if (length ==0 || length==1) return getLine(length);
for (iterationCounter=1; iterationCounter<=length;iterationCounter++){
line = "";
for (iterationCounter_2=1 ;iterationCounter_2<=length;iterationCounter_2++){
line +=" ";

}
for (iteration_Counter_3=1;iteration_Counter_3<=iterationCounter+2; iteration_Counter_3++{
line+="*";
shape+= line + "\n";
}
}
return shape;
}



function getCheckerboard(width, height) {
// TODO - write method definition here
let output="";

let iterationCounter;
let iterationCounter_2;
let iteration_Counter_3=1;

for( iterationCounter = 1; iterationCounter <= height; iterationCounter++) {
for(iterationCounter_2 = width; iterationCounter_2 > 0; iterationCounter_2--) {
if(iteration_Counter_3 % 2 == 0) {
output += "*";
}
else {
output += " ";
}
iteration_Counter_3++;
}
if(width % 2 == 0) { iteration_Counter_3++; }
output += "\n";
}
return output;

}