Fun Puzzles!-JavaScript dated 25/02/2023

It’s Time for Fun Puzzle!
Here I will Share you Some Code Please execute that and reply your answer.
1.What will be the output of the following code?

const x = [1, 2, 3];
x[-1] = -1;
console.log(x[x.indexOf(10000)]);

2.What will be the output of the following code?

console.log(2 + "2" + 2);

3.What will be the output of the following code

const y = 1;
const x = y = typeof x;
console.log(x);

4.What will be the output of the following code?

const a = [1, 2, 3];
const b = [...a, 4];
console.log(b);

5.What will be the output of the following code?

console.log(+"Infinity");

I Hope you will find this useful!

Have a Happy Learning
Thanks & Regards
Teaching Assistant,
Dharshini M.

1 Like

Good Afternoon Mam,

  1. -1
  2. 222
  3. Error
  4. [1,2,3,4]
    5.Infinity

@manohar.kota13 Thank you for your response! :grinning:
You have answered correctly.
Keep Learning…

Answer 1:-1
Answer 2 :222
Answer 3: Error
Answer 4 : [ 1, 2, 3, 4 ]
Answer 5: Infinity

@rrnayak2609 Thank you for your response! :grinning:
You have answered correctly.
Keep Learning…

-1
222
error
[1,2,3,4]
infinity

@ksaini613 Thank you for your response! :grinning:
You have answered correctly.
Keep Learning…