File tree 1 file changed +38
-0
lines changed
1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,15 @@ function gradeLabs(labs) {
2
2
for ( let i = 0 ; i < labs . length ; i ++ ) {
3
3
let lab = labs [ i ] ;
4
4
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
+
5
14
console . log ( `${ lab . student } code worked: ${ result === 27 } ` ) ;
6
15
}
7
16
}
@@ -21,4 +30,33 @@ let studentLabs = [
21
30
}
22
31
] ;
23
32
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
+
24
59
gradeLabs ( studentLabs ) ;
60
+
61
+ // Testing & Run 'gradeLabs' function using objects in 'studentLabs2'
62
+ gradeLabs ( studentLabs2 ) ;
You can’t perform that action at this time.
0 commit comments