AHMAD LMS

JavaScript Course

Learn JavaScript from beginner to practical level with clear lessons, practical examples and interactive exercises.

Course Progress

0 / 7 Lessons Completed

About This Course

Welcome to the JavaScript Course at Ahmad LMS. In this course, you will learn the fundamentals of JavaScript and understand how JavaScript adds interaction and functionality to web pages.

You will start with variables and data types, then move through conditions, functions, arrays, objects, events and practical DOM manipulation.

LESSON 01

What is JavaScript?

JavaScript is a programming language commonly used to make websites interactive and dynamic.

HTML provides structure, CSS provides design, and JavaScript provides behavior and interaction.

A Simple JavaScript Example

<script>

    alert("Hello World!");

</script>

Using JavaScript in an HTML File

<script src="js/script.js"></script>

The <script> element allows JavaScript code to run in an HTML document.

What Can JavaScript Do?

Next Lesson →
LESSON 02

Variables and Data Types

Variables are used to store information that a JavaScript program can use later.

Creating Variables

let name = "Ahmad";

const age = 25;

let country = "Pakistan";

Modern JavaScript commonly uses let and const for declaring variables.

Strings

let name = "Ahmad";

A string represents text.

Numbers

let age = 25;

let price = 99.99;

Boolean Values

let isStudent = true;

let isCompleted = false;

Simple Example

let name = "Ahmad";
let course = "JavaScript";

console.log(
    name + " is learning " + course
);

Variables are fundamental building blocks of JavaScript programs.

Next Lesson →
LESSON 03

Conditions and Operators

Conditions allow a program to make decisions based on different situations.

Comparison Operators

let age = 20;

console.log(age >= 18);

console.log(age === 20);

If Statement

let age = 20;

if (age >= 18) {

    console.log("You are an adult.");

}

If / Else

let age = 16;

if (age >= 18) {

    console.log("Access granted.");

} else {

    console.log("Access denied.");

}

Else If

let score = 80;

if (score >= 90) {

    console.log("Excellent");

} else if (score >= 70) {

    console.log("Good");

} else {

    console.log("Keep practicing");

}

Common Operators

Next Lesson →
LESSON 04

Functions

Functions are reusable blocks of code designed to perform a specific task.

Basic Function

function greet() {

    console.log("Hello Ahmad!");

}

Calling a Function

greet();

Function Parameters

function greet(name) {

    console.log("Hello " + name);

}

greet("Ahmad");

Returning a Value

function add(a, b) {

    return a + b;

}

let result = add(10, 20);

console.log(result);

Why Use Functions?

Next Lesson →
LESSON 05

Arrays and Objects

Arrays and objects allow us to organize and store multiple pieces of information.

Arrays

let courses = [
    "HTML",
    "CSS",
    "JavaScript"
];

console.log(courses[0]);

Array indexes normally start from 0.

Adding an Item

courses.push("GitHub");

Objects

let student = {

    name: "Ahmad",

    age: 25,

    course: "JavaScript"

};

Accessing Object Data

console.log(
    student.name
);

console.log(
    student.course
);

Practical Example

const user = {

    name: "Ahmad",

    country: "Pakistan",

    skill: "Web Development"

};

console.log(
    user.name
);
Next Lesson →
LESSON 06

DOM and Events

The DOM, or Document Object Model, allows JavaScript to interact with HTML elements.

Selecting an Element

const title =
    document.getElementById("title");

Changing Text

const title =
    document.getElementById("title");

title.textContent =
    "Welcome to Ahmad LMS";

Changing CSS

title.style.color =
    "blue";

Button Click Event

const button =
    document.getElementById("myButton");

button.addEventListener(
    "click",
    function () {

        alert("Button clicked!");

    }
);

Practical Example

Click the button to see JavaScript in action.

JavaScript events are important because they allow websites to respond to user interactions such as clicks, typing and form submissions.

Next Lesson →
LESSON 07

Form Validation and Practical JavaScript

JavaScript can be used to validate information entered into forms before the information is processed.

Basic Form Validation

const name =
    document.getElementById("name").value;

if (name.trim() === "") {

    alert("Please enter your name.");

}

Email Validation Concept

const email =
    document.getElementById("email").value;

if (!email.includes("@")) {

    alert("Enter a valid email.");

}

Combining HTML, CSS and JavaScript

A modern website often uses all three technologies together.

Practical Example

Final Challenge

Try to create a small web page that contains a heading, paragraph, button and form. Then use JavaScript to make the button interactive.

Congratulations! You have reached the final lesson of the JavaScript course.

What You Will Learn

After completing this course, you should have a foundation in JavaScript and understand how JavaScript can make websites interactive.

Course Navigation