0% found this document useful (0 votes)
12 views3 pages

Important JavaScript Basic Programs

The document provides a list of important basic JavaScript programs, including displaying messages, performing arithmetic operations, checking even or odd numbers, and creating a simple calculator. It also includes examples of using loops, user input, and alert boxes. Additionally, it mentions practicing model papers related to HTML practicals.

Uploaded by

sfatimazrashdi
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views3 pages

Important JavaScript Basic Programs

The document provides a list of important basic JavaScript programs, including displaying messages, performing arithmetic operations, checking even or odd numbers, and creating a simple calculator. It also includes examples of using loops, user input, and alert boxes. Additionally, it mentions practicing model papers related to HTML practicals.

Uploaded by

sfatimazrashdi
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Important JavaScript basic programs

1. Display Message
[Link]("Welcome to JavaScript");

2. Addition of Two Numbers


let a = 10;
let b = 5;
let sum = a + b;

[Link]("Sum = " + sum);

3. Check Even or Odd


let num = 7;

if (num % 2 == 0)
[Link]("Number is Even");
else
[Link]("Number is Odd");

4. Find Greater Number


let x = 15;
let y = 20;

if (x > y)
[Link]("X is greater");
else
[Link]("Y is greater");

5. Table of a Number
let n = 5;

for (let i = 1; i <= 10; i++) {


[Link](n + " x " + i + " = " + n*i + "<br>");
}

6. Simple Calculator
let a = 12;
let b = 4;

[Link]("Addition = " + (a+b) + "<br>");


[Link]("Subtraction = " + (a-b) + "<br>");
[Link]("Multiplication = " + (a*b) + "<br>");
[Link]("Division = " + (a/b) + "<br>");
7. Display 1 to 5 using Loop
for (let i = 1; i <= 5; i++) {
[Link](i + "<br>");
}

8. User Input with Prompt


let name = prompt("Enter your name");
[Link]("Welcome " + name);

9. Find Square of Number


let n = 6;
let square = n * n;

[Link]("Square = " + square);

10. Alert Box Program


alert("Hello Students");

HTML practical’s
Please practice the PBA model papers given at the end of the book.

You might also like