File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -19,14 +19,22 @@ Use console.log() to clearly show the before-and-after type conversions.
19
19
*/
20
20
21
21
22
- let result = "5" - 2 ;
22
+ let result = Number ( "5" ) - 2 ; //converting 5 to a number
23
23
console . log ( "The result is: " + result ) ;
24
24
25
- let isValid = Boolean ( "false" ) ;
25
+ let isValid = Boolean ( "false" ) ; //No errors, code is returning true already
26
26
if ( isValid ) {
27
27
console . log ( "This is valid!" ) ;
28
28
}
29
29
30
30
let age = "25" ;
31
- let totalAge = age + 5 ;
31
+ let totalAge = Number ( age ) + 5 ; //Added number to convert the string back into a number
32
32
console . log ( "Total Age: " + totalAge ) ;
33
+
34
+ //Impplicit
35
+ let implicit = null + 5 ;
36
+ console . log ( implicit )
37
+
38
+ //Explicit
39
+ let explicit = Number ( "Wet Orange 11" )
40
+ console . log ( explicit )
You can’t perform that action at this time.
0 commit comments