Question from the Javascript test

Write a Javascript code that prints the indexes of an array.

Hard

What will the following code display?

var names = ['Lea', 'John', 'Rachel', 'Yehuda'];
(function(){
    for(name in names){
        console.log(name);
    }
})();
Author: Jean-marie CléryStatus: PublishedQuestion passed 1948 times
Edit
7
Community Evaluations
developer avatar
Ludovic JIGAN
05/04/2024
Pour afficher les valeurs 'Lea', 'John', 'Rachel', 'Yehuda' il faut faire un for of
developer avatar
Afonso
06/04/2023
The code will display the index numbers of each element in the names array, as name represents the index and not the element itself. Therefore, the output will be: 0123