0% found this document useful (0 votes)
8 views1 page

Web Engineering Lab Task

The document outlines a Web Engineering Lab task focusing on JavaScript operators and scope. It includes examples of arithmetic operations, logical operations, and conditional (ternary) operators, as well as demonstrating variable scope through functions and block statements. Additionally, it features a mini program that performs basic arithmetic operations and checks the size of the sum.

Uploaded by

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

Web Engineering Lab Task

The document outlines a Web Engineering Lab task focusing on JavaScript operators and scope. It includes examples of arithmetic operations, logical operations, and conditional (ternary) operators, as well as demonstrating variable scope through functions and block statements. Additionally, it features a mini program that performs basic arithmetic operations and checks the size of the sum.

Uploaded by

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

Web Engineering Lab Task (JavaScript Operators

& Scope)
Name: ____________
Reg No: ____________
Section: ____________

// TASK 1: OPERATORS
let a = 10, b = 5;
[Link]("Addition:", a + b);
[Link]("Subtraction:", a - b);

let x = 10;
x += 5;
[Link]("x after += :", x);

[Link]("a == b:", a == b);


[Link]("a > b:", a > b);

[Link]("true && false:", true && false);


[Link]("true || false:", true || false);

let age = 18;


let result = (age >= 18) ? "Adult" : "Minor";
[Link]("Age Status:", result);

// TASK 2: SCOPE
let globalVar = "Global Variable";
function show() { [Link](globalVar); }
show();

function test() {
var localVar = "Inside Function";
[Link](localVar);
}
test();

{
let blockVar = "Block Variable";
[Link](blockVar);
}

function outer() {
let outerVar = "Outer";
function inner() { [Link](outerVar); }
inner();
}
outer();

(function () {
let privateVar = "Private";
[Link](privateVar);
})();

// TASK 3: MINI PROGRAM


let num1 = 20;
let num2 = 10;

let sum = num1 + num2;


let multiply = num1 * num2;
let divide = num1 / num2;

let check = (sum > 20) ? "Sum is Big" : "Sum is Small";

[Link]("Num1:", num1);
[Link]("Num2:", num2);
[Link]("Sum:", sum);
[Link]("Multiply:", multiply);
[Link]("Divide:", divide);
[Link]("Check:", check);

You might also like