Const is used to assign a value that never changes.
If the value of a “const” variable is changed by code, an error will occur.
<!DOCTYPE html>
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.29/browser.js"></script>
<script type="text/babel">
function coldEnough(deg) {
const freezingTemp = 32;
if (freezingTemp <= deg) {
return deg + " is above freezing";
} else {
return deg + " is below freezing";
}
}
function getRandomInt(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min)) + min; //The maximum is exclusive and the minimum is inclusive
}
console.log(coldEnough(getRandomInt(-100,100)));
console.log(coldEnough(getRandomInt(-100,100)));
console.log(coldEnough(getRandomInt(-100,100)));
</script>
<title>Const Keyword</title>
</head>
<body>
</body>
</html>