File tree Expand file tree Collapse file tree 1 file changed +28
-2
lines changed Expand file tree Collapse file tree 1 file changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -18,15 +18,41 @@ Use console.log() to clearly show the before-and-after type conversions.
18
18
19
19
*/
20
20
21
+ //Part 1
21
22
22
23
let result = "5" - 2 ;
23
24
console . log ( "The result is: " + result ) ;
24
25
25
- let isValid = Boolean ( "false" ) ;
26
+ /*
27
+ This is correct and reguired no change.
28
+ */
29
+
30
+ let isValid = Boolean ( "true" ) ;
26
31
if ( isValid ) {
27
32
console . log ( "This is valid!" ) ;
28
33
}
29
34
35
+ /*
36
+ isValid is a truthy, so it needed to be changed to "true".
37
+ */
38
+
30
39
let age = "25" ;
31
- let totalAge = age + 5 ;
40
+ let totalAge = ( Number ( age ) + 5 ) ;
32
41
console . log ( "Total Age: " + totalAge ) ;
42
+
43
+ /*
44
+ The variable age needed to be converted to a number from a string at line 39, so the numbers are added.
45
+ */
46
+
47
+ // Part 2
48
+ let currentYear = "2025" ;
49
+ let birthYear = "1992" ;
50
+ let myAge = ( Number ( currentYear ) - Number ( birthYear ) ) ;
51
+
52
+ console . log ( 'You are ' + ( myAge ) + ' years old.' ) ;
53
+
54
+ let bool1 = false ;
55
+ let num1 = null ;
56
+ bool1 == num1 ;
57
+
58
+ console . log ( num1 + bool1 )
You can’t perform that action at this time.
0 commit comments