You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: explicit-and-implicit-conversion-in-javascript.js
+30-4Lines changed: 30 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -19,14 +19,40 @@ Use console.log() to clearly show the before-and-after type conversions.
19
19
*/
20
20
21
21
22
-
letresult="5"-2;/*This Covers implicit conversion cause JavaScript converts the string to a number for you.*/
22
+
letresult="5"-2;//Correct:*This Covers implicit conversion cause JavaScript converts the string to a number for you.*/
23
23
console.log("The result is: "+result);
24
24
25
-
letisValid=Boolean("false");/*This is an edge case because non empty strings in java script are always true so even though it says false it is valid.*/
25
+
letisValid=Boolean("false");//Correct:*This is an edge case because non empty strings in java script are always true so even though it says false it is valid.*/
26
26
if(isValid){
27
27
console.log("This is valid!");
28
28
}
29
29
30
-
letage=Number("25");/*Wrapping this string with a number conversions so that on line 31 the types are the same. This would also be an explicit conversion.*/
31
-
lettotalAge=age+5;
30
+
letage=Number("25");//Incorrect:*Wrapping this string with a number conversions so that on line 31 the types are the same. This would also be an explicit conversion.*/
0 commit comments