Skip to content

Commit 90218f1

Browse files
committed
Explicit and Implicit conversions
1 parent ce92942 commit 90218f1

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

main.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// let result = "5" - 2; we can covert this to a string the results are he same.
2+
let result = String (("5" - 2));
3+
console.log("The result is: " + result);
4+
5+
// let isValid = Boolean("false");
6+
let isValid = Boolean("flase");
7+
if (isValid) {
8+
// console.log("This is valid."); convert this line to boolean. because it is a text this is true.
9+
console.log(Boolean("This is valid"));
10+
11+
}
12+
13+
let age = "25";
14+
// let totalAge = age + 5; (convert 25 into a number)
15+
let totalAge = Number (age) + 5;
16+
console.log("Total Age: " + totalAge);
17+
18+
let inValid = 0
19+
console.log(Boolean(inValid));
20+
21+
let studentGrade = 83.5
22+
console.log(parseInt(studentGrade));

0 commit comments

Comments
 (0)