-
Notifications
You must be signed in to change notification settings - Fork 69
/
Copy pathkonversi-string-dan-number.html
42 lines (33 loc) · 1.07 KB
/
konversi-string-dan-number.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Konversi String dan Number</title>
</head>
<body>
<script>
const value1 = parseInt("1");
const value2 = 1;
const sum = value1 + value2;
document.writeln(`<p>${sum}</p>`)
document.writeln(`<p>${parseInt("1.9")}</p>`)
document.writeln(`<p>${parseFloat("1.1")}</p>`)
document.writeln(`<p>${Number("1.1")}</p>`)
const a = 1;
const b = 1;
const total = a.toString() + b.toString();
document.writeln(`<p>${total}</p>`);
document.writeln(`<p>${parseInt("1salah")}</p>`)
document.writeln(`<p>${parseFloat("1.1eko")}</p>`)
document.writeln(`<p>${Number("1salah")}</p>`)
document.writeln(`<p>${Number("1.1eko")}</p>`)
document.writeln(`<p>${Number("salah")}</p>`)
const first = Number("salah"); // NaN
const totalNumber = first + 100;
document.writeln(`<p>${totalNumber}</p>`);
document.writeln(`<p>${isNaN(first)}</p>`);
document.writeln(`<p>${isNaN(100)}</p>`);
document.writeln(`<p>${isNaN(NaN)}</p>`);
</script>
</body>
</html>