JavaScript Essentials

Master the fundamentals with clean, focused examples

🏗

HTML Structure

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>
💬

Alerts

Show popup messages to users

alert("Welcome to JavaScript!");
🔍

Prompts

Ask questions and get user input

prompt("What's your favorite movie?");
📦

Variables

Store information in labeled boxes

// Text variables
let schoolName = "Tech Academy";
let subject = "JavaScript";

// Number variables
let students = 25;
let lessons = 10;
💾

User Input

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");

Quick Pattern

The basic flow to remember

// 1. Get input
let userInput = prompt("Ask your question");

// 2. Use the input
alert("You said: " + userInput);