From 6d987af3c82099902886326c702b5fe2639d3473 Mon Sep 17 00:00:00 2001 From: shoulansi Date: Tue, 11 Mar 2025 19:37:39 -0500 Subject: [PATCH] all changes made --- ...t-and-implicit-conversion-in-javascript.js | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/explicit-and-implicit-conversion-in-javascript.js b/explicit-and-implicit-conversion-in-javascript.js index ede0ccd..b244551 100644 --- a/explicit-and-implicit-conversion-in-javascript.js +++ b/explicit-and-implicit-conversion-in-javascript.js @@ -19,14 +19,29 @@ Use console.log() to clearly show the before-and-after type conversions. */ -let result = "5" - 2; +let result = Number("5") - 2; +//Turned string 5 into an integer 5, same result. console.log("The result is: " + result); -let isValid = Boolean("false"); +let isValid = false; +//Strings are considered a true value, having "false" would always make it true. if (isValid) { console.log("This is valid!"); } let age = "25"; -let totalAge = age + 5; +let totalAge = (Number(age)) + 5; +//Adding the Number() explicit converison turns the age string into an integer allowing for total age to calculate. console.log("Total Age: " + totalAge); + + +let bigNumber = "175" - 27; +console.log(bigNumber); +//This is my implicit code. + +console.log(String(null)); +//Here are some explicit examples. +let notANumber; +console.log(notANumber) + +console.log(Number("A")) \ No newline at end of file