File tree 1 file changed +13
-3
lines changed 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -19,14 +19,24 @@ 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 = "5" - 2 ; // This is Correct as 5-2 is 3. THis is an example of implicit conversion
23
23
console . log ( "The result is: " + result ) ;
24
24
25
- let isValid = Boolean ( " false" ) ;
25
+ let isValid = Boolean ( false ) ; // I fixed this so it does not run the statement as it is False.
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 realAge = Number ( age ) ; // I converted the string to a number so it does the proper calcualtion instead of a string concatenation
32
+ let totalAge = realAge + 5 ;
32
33
console . log ( "Total Age: " + totalAge ) ;
34
+
35
+
36
+ console . log ( "5" * "10" ) ; // THis is implicit as the computer automatically converts these strings to numbers
37
+
38
+ let isLaughing = true ;
39
+ console . log ( isLaughing . toString ( ) ) ; //I explicity made this boolean convert to a string.
40
+
41
+ let num = NaN ;
42
+ console . log ( Boolean ( num ) ) ; // Using a edge case, the variable humber is false becuase it is not a number
You can’t perform that action at this time.
0 commit comments