Page 1 of 1

JavaScript: Alerts, Comments, and Variables

Posted: Tue Dec 30, 2025 12:06 am
by Jason

Code: Select all

<!DOCTYPE html>

<html>

<head></head>

<body>

<!-- ambers-profile-page.htm -->

<h2>Amber's Profile Page</h2>

<script>

function Profile{

// This is a comment.

/* This is a
multi-line comment */

// let variables has block scope

// Variables can start with letters, underscored, and dollar signs.

// The rest of a variable can contain the same and also numbers.

let _name = "Amber";

let $age = 50;

alert("${name} is ${$age} years old today.");

}

</script>

<button onclick = "Profile()">Click for Amber's Profile</button>

</body>

</html>