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
10 changes: 10 additions & 0 deletions JavaScript-Loops-Lab.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>
<head>

</head>
<body>
<main></main>
<script src="JavaScript-Loops-Lab.js"></script>
</body>
</html>
80 changes: 80 additions & 0 deletions JavaScript-Loops-Lab.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
// Part 1

for (i = 0; i <= 10; i++) {
console.log(i);

}

//part 2

for (i = 1; i <= 10; i++) {
console.log(i*i);
}


//part 3
let n = 20;
for (i = 0; i <=n; i+=2) {
console.log (i);
}

/*part 4
numberSum = (n,m) => {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incomplete (-12)

let total = 0;
for
}
}
console.log(numberSum()); */


// challenge 5

/*let answer = prompt("Are we there yet?")
if(answer === "yes"){
console.log("good");
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes displays twice if you answer yes on the first prompt (-3)


} else {
while (answer !== "yes")
answer= prompt("Are we there yet?");
}

console.log("good");*/

// 6 Triangle

let triangle = " ";

for (let i=1; i <= 12; i++) {
triangle += i + " ";
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be * instead of numbers (-1)

console.log(triangle);
}



// 7

let output="";let count = 0;
for (let i = 1; i <= 4; i++)
{

for (let j = 0; j < 4; j += 1)
{
output +=(count+1)+"\t";count ++;
}output+="\n";

}
console.log(output);

//8
let output="";let count = 0;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should work of a variable n, similar to what you did on problem 3 (-3)

for (let i = 1; i <= 6; i++)
{

for (let j = 0; j < 6; j += 1)
{
output +=(count+1)+"\t";count ++;
}output+="\n";

}
console.log(output);