Fun Puzzles dated 11/03/2023

Hello Everyone!
Please solve this and post your answer.

1)Which of the following is used to add a new element to an array in JavaScript?

a) append()

b) add()

c) push()

d) concat()

  1. What is the output of the follow
ing code snippet?

var x = 10;

var y = "5";

console.log(x == y);

a) true

b) false

c) NaN

d) Syntax error

3)Which of the following is used to remove the last element from an array in JavaScript?

a) pop()

b) shift()

c) slice()

d) splice()
4. What is the output of the following code snippet?


var x = 10;

if (x == "10") {

console.log("x is equal to 10");

} else {

console.log("x is not equal to 10");

}

a) x is equal to 10

b) x is not equal to 10

c) NaN

d) Syntax error

5)Which of the following is used to generate a random number between 0 and 1 in JavaScript?

a) Math.random()

b) Math.floor()

c) Math.ceil()

d) Math.round()

Have a Happy Learning

Thanks & Regards

Teaching Assistant,
Dharshini M.

1 Like
  1. push()
    2 false
    3.pop()
    4.x is equal to 10
  2. Math.random()