Javascript Quiz: How Well Do You Know "forEach()" method in JS

Опубликовано: 04 Октябрь 2024
на канале: Programming Geek
117
4

Are you ready for another code challenge? Join me in this video as you test your coding knowledge with the simple quiz questions.

Don't forget to make your guess in the comments below.

-------------------------------------------------------------------------------------------

🔔Like and subscribe for more videos. 🔔

Connect me on linkedin :
https://www.linkedin.com/in/meenakshilodhi...
https://www.linkedin.com/in/rk-barnwal23/
------------------------------------------------------------------------------------------

Answer OPTION:- A) 1 3

Explanation:
The forEach() method iterates over each element of the array and applies a function to each element. In this case, the function checks whether the current element is equal to 2. If it is, the function returns immediately and does not execute any further code. Therefore, the value 2 is not printed to the console.

For all other values, the function executes the console.log(x) statement, which prints the value of the current element to the console. Therefore, the output of the code is 1 3.