• Post author:
  • Post category:Blog
  • Reading time:1 mins read
  • Post last modified:June 12, 2024

Analyze the code snippet:

let summer = ["June", "July", "August"];
let index = summer.indexOf("June");

The index variable will have the value:

  • 0
  • 1
  • True
  • "June"
Answers Explanation & Hints:

The indexOf() method is used to find the index of the first occurrence of a specified element within an array. In this case, it is used to find the index of the string “June” within the summer array.

Since arrays in JavaScript are zero-based, meaning the first element has an index of 0, the indexOf() method will return the index of “June” as 0. Therefore, the variable index will have the value 0.

For more Questions and Answers:

JavaScipt Essentials 1 (JSE) | JSE1 – Module 2 Test Exam Answers Full 100%

Subscribe
Notify of
guest
0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments