First Element

Completed Code

var arr=[ 'We', 'love', 'learning', 'JavaScript!','It', 'is', 'a', 'fantastic', 'language' ];

first = function(array) {
    return array[0];
};

console.log(first(arr));

Explanation

Remember, arrays are zero-based, which means that the first element will have an index of 0. All we need to do with our function is return the value with an index of 0. In this specific example, that happens to be We.

Last updated