Skip to content

Commit 0561338

Browse files
committed
new
1 parent 4fc2b43 commit 0561338

File tree

5 files changed

+157
-0
lines changed

5 files changed

+157
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<script src="example1.js"></script>
4+
<script src="example2.js"></script>
5+
<script src="example3.js"></script>
6+
<script src="example4.js"></script>
7+
8+
<div style="margin-top: 250px">
9+
<div style="width:150px; height:150px; border:3px solid #5C68B0; text-align: center; margin: 10px; float: right; margin-right: 100px;">
10+
<button onclick="checkPoint4()" style="margin-top: 60px;">Checkpoint 4</button>
11+
</div>
12+
<div style="width:150px; height:150px; border:3px solid #5C68B0; text-align: center; margin: 10px; float: right; margin-right: 100px;">
13+
<button onclick="checkPoint3()" style="margin-top: 60px;">Checkpoint 3</button>
14+
</div>
15+
<div style="width:150px; height:150px; border:3px solid #5C68B0; text-align: center; margin: 10px; float: right; margin-right: 100px;">
16+
<button onclick="checkPoint2()" style="margin-top: 60px;">Checkpoint 2</button>
17+
</div>
18+
<div style="width:150px; height:150px; border:3px solid #5C68B0; text-align: center; margin: 10px; float: right; margin-right: 100px;">
19+
<button onclick="checkPoint1()" style="margin-top: 60px;">Checkpoint 1</button>
20+
</div>
21+
</div>
22+
</html>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/**
2+
* Description: This program is locked into an infinite loop. Your task is to run and debug the program.
3+
*
4+
* TODO: The program should exit the loop after counting down from 5 to 1. You should check to make sure the boolean statement
5+
* is being updated.
6+
*/
7+
8+
function checkPoint1() {
9+
alert1();
10+
11+
let array = [];
12+
let x = 0;
13+
14+
// TODO: Remove the bugs from the code below.
15+
function getMultiples() {
16+
while (x <= 50){
17+
array.push(x + 2);
18+
x++;
19+
}
20+
return array;
21+
}
22+
console.log(getMultiples());
23+
24+
// DO NOT CHANGE THE CODE BELOW
25+
alert2();
26+
}
27+
28+
29+
/************************************************ DONT CHANGE THE CODE BELOW ******************************************************/
30+
function alert1() {
31+
alert("Oh no! It looks like you are trapped in an infinite loop. Go to the example1.js file and work on checkpoint 1.");
32+
}
33+
34+
function alert2(){
35+
alert("Congratulations! You have passed checkpoint 1!");
36+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/**
2+
* Description: This program is assigning student IDs to 5 new students but there is a bug in the code preventing the code to run
3+
* as expected. Your task is to run and debug the program using breakpoints.
4+
*
5+
* TODO: The program has error message in the console. You should read the message and debug accordingly. The final
6+
* goal is to print out a student ID for each student to the console. The ID numbers should be from 0 to 4.
7+
*/
8+
9+
function checkPoint2(){
10+
alert3();
11+
12+
// TODO: Remove the bugs from the code below.
13+
const friends = ["Rei", "Miya", "Alexis", "Ethan", "Anna"];
14+
const studentID = [];
15+
16+
for (let i = 0; i < friends.length; i++){
17+
studentID.push("JSMIT" + i);
18+
}
19+
console.log(studentID);
20+
21+
// DO NOT CHANGE THE CODE BELOW
22+
alerts(studentID);
23+
}
24+
25+
26+
/************************************************ DONT CHANGE THE CODE BELOW ******************************************************/
27+
function alert3() {
28+
alert("All students need to get their student IDs, but it seems like the system is down. Can you help debug the system? Go to the example2.js file and work on checkpoint 2.");
29+
}
30+
31+
function alerts(studentID) {
32+
if (studentID.length == 5) {
33+
alert("Yay! You got the system running!");
34+
}
35+
else {
36+
alert("Hmmm! It seems like Rei hasn't received his ID. Keep debugging!");
37+
}
38+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/**
2+
* Description: This program is calculating the amount of change given to the customer after buying groceries but there is a bug
3+
* in the code preventing the code to run as expected. Your task is to run and debug the program using the console to print
4+
* statements.
5+
*
6+
* TODO: The program currently displays NaN in the console as the returned change. You should check and make sure the function
7+
* is reading the passed parameters.
8+
*/
9+
10+
function checkPoint3(){
11+
alert4();
12+
13+
// TODO: Remove the bugs from the code below.
14+
function superMarket(cash) {
15+
let milk = 4.99;
16+
let vegetables = 15.99;
17+
let bread = 2.99;
18+
19+
let total = milk + vegetables + bread;
20+
cash = cash - total;
21+
22+
return cash;
23+
}
24+
25+
function main(cash) {
26+
let moneySpent = superMarket(cash);
27+
return moneySpent;
28+
}
29+
30+
let totalCash = 50.00;
31+
console.log("Total Cash: $" + totalCash);
32+
console.log("Change Return = $" + main(totalCash));
33+
34+
35+
// DO NOT CHANGE THE CODE BELOW
36+
if (main(totalCash) < 50) {
37+
alert("Awesome work! You got the system running!");
38+
}
39+
}
40+
41+
42+
/************************************************ DONT CHANGE THE CODE BELOW ******************************************************/
43+
function alert4() {
44+
alert("The system at the supermarket doesn't seem to be working. Can you help debug the system to help calculate the total change return to the customer? Go to the example3.js file and work on checkpoint 3.");
45+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/**
2+
* Description: This program is asking the user to create a new password for their account but there is a bug
3+
* in the code preventing the code to run as expected. Your task is to run and debug the program by reading the error message.
4+
*
5+
* TODO: The program has an error message in the console. You should read the message and debug accordingly.
6+
*/
7+
8+
function checkPoint4() {
9+
// TODO: Remove the bugs from the code below.
10+
let password="";
11+
12+
while (password.length != 10) {
13+
password = prompt("New password must be 10 characters:");
14+
}
15+
alert("Your new password: " + password);
16+
}

0 commit comments

Comments
 (0)