Q1.
Consider the following program:
let x = 5;
if (x == 6) {
console.log("Hello");
}
else {
console.log("Hi");
}What will be the output in the console?
You have to predict the output yourself without running/executing the code.
- Hello
- Hi
- Error
Q2.
Consider the following program:
let x = 10;
let y = 20;
if (x == 10) {
if (y == 20) {
console.log("x is 10 and y is 20");
}
else {
console.log("x is 10 but y is not 20");
}
}
else {
console.log("x is not 10");
}What will be the output in the console?
You have to predict the output yourself without running/executing the code.
- x is 10 and y is 20
- x is 10 but y is not 20
- x is not 10
- No output due to an error
Q3.
Consider the following program:
let age = 25;
if (age > 18)
console.log("Adult");
else if (age > 12)
console.log("Teenager");
else if (age > 5)
console.log("Child");
else
console.log("Toddler");What will be the output in the console?
You have to predict the output yourself without running/executing the code.
- Adult
- Teenager
- Child
- Toddler
Q4.
let x = 10;
let y = 20;
if (x > 5)
console.log("A");
else if (y > 15)
console.log("B");
else
console.log("C");What will be the output?
You have to predict the output yourself without running/executing the code.
- A
- B
- C
- No output due to an error
Q5.
Create a system to calculate popcorn prices based on the bucket size customer asks for:
Here, the list for price per bucket-size is given -
- ‘XL’ : price is rs.250
- ‘L’ : price is rs.200
- ‘M’ : price is rs.100
- ‘S’ : price is rs.50
Expected Output:
Enter the popcorn-bucket size: M
Price: 100Q6.
Create a program to make a mini-calculator.
Take 2 numbers and the operator sign as input from the user, then give the result based on those taken values.
for e.g.
number1 : 3
number2 : 5
operator : *
// expected output
5 * 3 = 15All the operators should be covered, i.e. +, -, *, /, %, **.