0% found this document useful (0 votes)
2 views2 pages

Assignment

The document explains conditional statements and loops in programming. It provides examples of if-else statements, various types of loops (for, for-of, for-in, while, and do-while), and demonstrates how to execute code based on conditions and iterations. Additionally, it includes practical examples of using loops to print numbers within specified ranges.

Uploaded by

kishb630
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)
2 views2 pages

Assignment

The document explains conditional statements and loops in programming. It provides examples of if-else statements, various types of loops (for, for-of, for-in, while, and do-while), and demonstrates how to execute code based on conditions and iterations. Additionally, it includes practical examples of using loops to print numbers within specified ranges.

Uploaded by

kishb630
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
You are on page 1/ 2

Q1.

Conditional statements are what allow different blocks of code to be


executed under certain conditions.

if (true) {
console.log("It is true")
} else {
console.log("It is false")
}

Q2.
let grades = 65
if (grades >= 90) {
console.log("A grade")
} else if (grades >= 70 && grades < 90) {
console.log("B grade")
} else if (grades >= 50 && grades < 70) {
console.log("C grade")
} else {
console.log("F grade")
}

Q3.
Loops are what continues a block of code until a certain condition is
met.

for loop
for (let i = 0; i < 9; i++) {
console.log(i)
}

for-of
let details = [1, 2, 3, 4, 5]
for (let i of details) {
console.log(i)
}

for-in loop
let details = {
name: "Kishor",
age: 20,
place: "Kolkata"
}
for (let i in details) {
console.log(i)
}

while loop
let i = 0
while (i < 9) {
console.log(i)
i++
}

Do-while loop
let i = 9
do {
console.log(i)
} while (i<6)

Q4.
let [num1, num2] = [10, 25]
for (let i = num1+1; i <= num2; i++){
console.log(i)
}

Q5.
let i = 1;
while (i <= 25) {
console.log(i)
i++
}

let i = 25
while (i>0) {
console.log(i)
i--
}

You might also like