From 9632650672aebeb710cd9ba8636dab67b1583100 Mon Sep 17 00:00:00 2001 From: Daisie Date: Wed, 12 Mar 2025 20:05:19 -0500 Subject: [PATCH] //3/12/25 --- ...t-and-implicit-conversion-in-javascript.js | 30 +++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/explicit-and-implicit-conversion-in-javascript.js b/explicit-and-implicit-conversion-in-javascript.js index ede0ccd..28542d0 100644 --- a/explicit-and-implicit-conversion-in-javascript.js +++ b/explicit-and-implicit-conversion-in-javascript.js @@ -18,15 +18,41 @@ Use console.log() to clearly show the before-and-after type conversions. */ +//Part 1 let result = "5" - 2; console.log("The result is: " + result); -let isValid = Boolean("false"); +/* +This is correct and reguired no change. +*/ + +let isValid = Boolean("true"); if (isValid) { console.log("This is valid!"); } +/* +isValid is a truthy, so it needed to be changed to "true". +*/ + let age = "25"; -let totalAge = age + 5; +let totalAge = (Number(age) + 5); console.log("Total Age: " + totalAge); + +/* +The variable age needed to be converted to a number from a string at line 39, so the numbers are added. +*/ + +// Part 2 +let currentYear = "2025"; +let birthYear = "1992"; +let myAge = (Number(currentYear) - Number(birthYear)); + +console.log('You are ' + (myAge) + ' years old.'); + +let bool1 = false; +let num1 = null; +bool1 == num1; + +console.log(num1 + bool1) \ No newline at end of file