Q: What does "return" do?
A: It exits the function. Immediately.
BEFORE your loop has a chance to print anything else besides "orange".
You should NOT call return
until you're "finished" with everything the function needs to do.
SUGGESTIONS:
Array" is probably a poor name from a function.
What is it you want the function to do?
For example, maybe you want it to "print array". In that case:
function printArray(whatever) {
for (var i=0; i<whatever.length; i++) {
console.log("whatever[" + i + "]: " + whatever[i]);
}
}
var list = Array(['orange','cat','mouse','dog','pen']);
printArray(list);
Familiarize yourself with MDN (Mozilla Developers Network).
Here's a great introductory tutorial:
https://developer.mozilla.org/en-US/docs/Learn/Getting_started_with_the_web/JavaScript_basics