Number function convert value to number. In this example, we declare multiple variable like: var a = false; var b = true; var c = new Date(); var d = "888"; var e= "666 555"; and will get result into 0 1 1450198829985 888 NaN
<!DOCTYPE html>
<html>
<head>
<title>Welcome to LearnKode - A code learning platform</title>
</head>
<body>
<button onclick="convertToNumber()">Convert variables to numbers</button>
<p id="sample"></p>
<script>
function convertToNumber() {
var a = false;
var b = true;
var c = new Date();
var d = "888";
var e= "666 555";
var result =
Number(a) + "<br>" +
Number(b) + "<br>" +
Number(c) + "<br>" +
Number(d) + "<br>" +
Number(e);
document.getElementById("sample").innerHTML = result;
}
</script>
</body>
</html>