Skip to content

Commit 2bd6751

Browse files
committed
Modified some comments for clarity.
1 parent a076f4f commit 2bd6751

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

explicit-and-implicit-conversion-in-javascript.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ let newAge = Number("25"); // here, casting the string "25" to a number allows a
4545
let newTotalAge = newAge + 5;
4646
console.log("Total Age: " + newTotalAge);
4747

48-
// One example of implicit type conversion.
48+
4949
/*Here, I have explicitly cast the string representing a decimal
5050
to an integer to give a ballpark amount of money.*/
5151
let money = '10.78';
@@ -55,14 +55,15 @@ console.log("I have about $" + parseInt(roundedMoney) + " dollars.")
5555
//Displaying the tpe of values
5656
console.log("I've converted it into a: " + typeof(roundedMoney) + ".");
5757

58-
/*One example of explicit type conversion.
58+
/*One example of implicit type conversion.
5959
Here we are defining a number variable, but the if statement is
60-
explicitly converting the statement to a boolean to see if it is a number.
60+
implicitly converting the statement to a boolean to see if it is a number.
6161
I did not cast anything.*/
6262
let randomNumber = Math.random(2);
6363
console.log("Your random number is: " + randomNumber + ". Which is a: " + typeof(randomNumber));
6464
if (randomNumber == NaN){
6565
console.log(randomNumber + " is not a rumber.");
6666
}else{
6767
console.log(randomNumber + " is a number.");
68-
}
68+
}
69+

0 commit comments

Comments
 (0)