Can someone help me understand this code snippet?
function listArrayItems(arr) {
for (var i = 0; i < arr.length; i++) {
console.log(i, arr[i])
}
}
var colors = ['red', 'orange', 'yellow', 'green', 'blue', 'purple', 'pink'];
listArrayItems(colors);
I've been trying to figure out the .length property but I'm still confused. According to my research, it returns the number of characters in a string, and if the string is empty then the length will be 0. Also, can someone explain what console.log(i, arr[i]) is doing here? Any help would be greatly appreciated!***