Skip to content

Commit 124a7e6

Browse files
Charlene TranCharlene Tran
Charlene Tran
authored and
Charlene Tran
committed
still working
1 parent 6b51fbe commit 124a7e6

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

exceptions/exercises-CT/test-student-labs.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@ function gradeLabs(labs) {
22
for (let i=0; i < labs.length; i++) {
33
let lab = labs[i];
44
let result = lab.runLab(3);
5+
6+
// Added a Try/Catch block to catch an Exception if the 'runLab' property is not defined.
7+
try {
8+
//
9+
} catch(err) {
10+
//
11+
}
12+
13+
514
console.log(`${lab.student} code worked: ${result === 27}`);
615
}
716
}
@@ -21,4 +30,33 @@ let studentLabs = [
2130
}
2231
];
2332

33+
34+
// Created new array called 'studenLabs2'
35+
let studentLabs2 = [
36+
{
37+
student: 'Blake',
38+
myCode: function(num) {
39+
return Math.pow(num, num);
40+
}
41+
},
42+
{
43+
student: 'Jessica',
44+
runLab: function(num) {
45+
return Math.pow(num, num);
46+
}
47+
},
48+
{
49+
student: 'Mya',
50+
runLab: function(num) {
51+
return num * num;
52+
}
53+
},
54+
];
55+
56+
57+
58+
2459
gradeLabs(studentLabs);
60+
61+
// Testing & Run 'gradeLabs' function using objects in 'studentLabs2'
62+
gradeLabs(studentLabs2);

0 commit comments

Comments
 (0)