Page 1 of 1

JavaScript: Variables

Posted: Sun Aug 03, 2025 10:20 am
by The Jason

Code: Select all

<!DOCTYPE html>

<html>

<head><title>JavaScript Examples</title></head>

<body>

<script>

let x = 2;

// The line above represents the declaration of a variable with the integer value of 2.

// The integer data type, as with other ones, is not declared.

document.GetElementByID("demo").innerHTML = x;

// The line above prints out "2".

let name = Barry;

document.GetElementByID("demo").innerHTML = name;

// The line above prints out "Barry".

</script>


</body>

</html>