JavaScript Essentials

18 May 2025 • 1 min read

Variables

We can declare variables in three ways 1. var (function scoped) 2. let (block scoped) 3. const (block scoped)


Functions and loops

JAVASCRIPT
// Function to print student result
        function PrintResult(rollNum) {
            alert("Username with roll number " + rollNum + " has passed the exam");
            // any other logic to the display result
        }

        for (let i = 0; i < 100; i++) {
            PrintResult(rollNumbers[i]); // this will be called 100 times 
        }
    

If condition

JAVASCRIPT
age = prompt("What is your age")
        if (age >= 18) {
            document.getElementById("message").innerHTML = "You are an adult.";
        } else {
            document.getElementById("message").innerHTML = "You are a minor.";
        }

Start searching

Enter keywords to search articles.