Master the fundamentals with clean, focused examples
The foundation every webpage needs
<!DOCTYPE html>
<html>
<head>
<title>My Page</title>
</head>
<body>
<h1>Hello World</h1>
<script>
// Your code here
</script>
</body>
</html>
Show popup messages to users
alert("Welcome to JavaScript!");
Ask questions and get user input
prompt("What's your favorite movie?");
Store information in labeled boxes
// Text variables
let schoolName = "Tech Academy";
let subject = "JavaScript";
// Number variables
let students = 25;
let lessons = 10;
Store user answers in variables
// Store user input
let movieTitle = prompt("Favorite movie?");
let rating = prompt("Rate it 1-10:");
// Use stored input
alert("You rated " + movieTitle + " as " + rating + "/10");
The basic flow to remember
// 1. Get input
let userInput = prompt("Ask your question");
// 2. Use the input
alert("You said: " + userInput);