I'm currently trying to print out the values of an array in JavaScript and I keep receiving 'undefined' output in the Chrome developer console where I'm running the following code:
function printArray(){
var arr = [];
for (var i = 0; i < arr.length; i++){
arr = arr[i];
}
}
printArray(['hello','world',1,2,3]);
Will someone please point out to me what I am doing wrong here that is preventing me from seeing the following returned in the console?
['hello','world',1,2,3]
Additionally I've tried wrapping my call to the printArray function inside of a console.log(); statement.
console.log(printArray(['hello','world',1,2,3]));