ONTUT

JavaScript 101 - Tutorial

Learn the fundamentals of JavaScript through interactive examples and hands-on practice.

Tutorial 1 of 20

Getting Started with JavaScript

JavaScript is a versatile programming language used for both client-side and server-side development. This tutorial will teach you the basics of declaring variables, writing functions, and manipulating the DOM.


// Basic variable declarations
let message = "Hello, world!";
const pi = 3.14159;

// Simple function
function greet(name) {
    return `Welcome, ${name}!`;
}

console.log(greet("Student"));

Interactive Example

Try entering different values into the input below to see JavaScript in action. Press Enter after typing to execute the script.

DOM Manipulation

JavaScript allows you to modify HTML content dynamically. Let's create a simple counter application.


// HTML: <button id="counter">Count: 0</button>

document.getElementById("counter").addEventListener("click", () => {
    let count = parseInt(this.innerText.split(": ")[1]);
    this.innerText = `Count: ${count + 1}`;
});