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
66 changes: 50 additions & 16 deletions assets/js/footer-functions.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,70 @@
getLineTests();
getBoxTests();
//getBoxTests();
getBottomLeftTriangleTests();
getUpperLeftTriangleTests();
getPyramidTests();
getCheckerboardTests();
//getPyramidTests();
//getCheckerboardTests(); **/




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

function getLineTests()
{
var result;
result = getLine();
console.log("result=" +result);

}


function testGetLine(expectedOutput, numberOfStars)
{

let output =getLine(numberOfStars);

console.log("output = \n" + output);





/** console.log("Testing `" + methodName + "`");
console.log("first argument = `" + arg1 + "`")
console.log("second argument = `" + arg2 + "`")
let output = func(arg1, arg2);
let pass = output == expectedOutput
console.log("output = \n" + output);
console.log("expected = \n" + expectedOutput);
console.log("test pass = " + pass);
console.log("------------------------------------")
console.log("------------------------------------") **/

}



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

getBox();
// console.log("output=" +output);
//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);
getBottomLeftTriangle();
// testGetBottomLeftTriangle("*", 1);
// testGetBottomLeftTriangle("*\n**", 2);
// testGetBottomLeftTriangle("*\n**\n**", 3);
}

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


Expand Down
4 changes: 3 additions & 1 deletion assets/js/header-functions.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
function testGetLine(expectedOutput, numberOfStars) {
test(expectedOutput, getLine, numberOfStars);
// getLine(length);


}

function testGetBox(expectedOutput, width, height) {
Expand Down
52 changes: 43 additions & 9 deletions assets/js/shapes.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,56 @@
function getLine(length) {
// TODO - write method definition here
}
function getLine() {

var output="";
var length=prompt("enter the length");
for(var i=0;i<length;i++) {
output+="*";
}
return output;
}

// TODO - write method definition here
function getBox() {
let output="";
var width=prompt("enter the width");
var height=prompt("enter the height");
for(let row=1;row<=width;row++) {
output="";
for(let column=1;column<=height;column++) {
output +="*";
}
console.log("\n"+"Column "+output);
}
}
// TODO - write method definition here


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


function getBottomLeftTriangle() {
var output ="";
var length=prompt("enter the length");
for(i=0;i<=length;i++)
{
output += "*";
console.log(output +"\n");
}

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


function getUpperLeftTriangle(length) {
// TODO - write method definition here
function getUpperLeftTriangle() {
var output="";
var length=prompt("enter the length");
for(i=length;i>=1;i--)
{
output="";
for(j=1;j<=i;j++)
{
output +="*";
}
console.log(output +"\n");
}
}


Expand Down
11 changes: 9 additions & 2 deletions assets/js/utils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
function test(expectedOutput, func, arg1) {
/**function test(expectedOutput, func, arg1) {

console.log("Sudhakar here 3");
_test(func.name, expectedOutput, func, arg1);
}

Expand All @@ -9,11 +11,15 @@ function test(expectedOutput, func, arg1, arg2) {

// deprecated; too lazy to refactor; decorated instead
function _test(methodName, expectedOutput, func, arg1) {

console.log("Sudhakar here 4");
__test(methodName, expectedOutput, (arg1, arg2) => func(arg1), arg1, arg1);
}

// deprecated; too lazy to refactor; decorated instead
function __test(methodName, expectedOutput, func, arg1, arg2) {
console.log("Sudhakar here 5");

console.log("Testing `" + methodName + "`");
console.log("first argument = `" + arg1 + "`")
console.log("second argument = `" + arg2 + "`")
Expand All @@ -24,4 +30,5 @@ function __test(methodName, expectedOutput, func, arg1, arg2) {
console.log("test pass = " + pass);
console.log("------------------------------------")
console.log("------------------------------------")
}
}
**/