JavaScript: Alerts, Comments, and Variables

Post Reply
User avatar
Jason
Site Admin
Posts: 973
Joined: Sun Dec 21, 2025 8:56 pm
Contact:

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>



 

POSTREACT(ions) SUMMARY

Post Reply