Having some difficulty with this code for my assignment.
I'm supposed to create two functions.
the first function is called
calledInLoopthat will accept one parameter and log the parameter.calledInLoop = function (parameter) { console.log(parameter); }the second function is called
loopThroughthat will accept an array, loop through each, and invoke thecalledInLoopfunction. The result should be each element of the array is console logged.loopThrough = function (array) { for (var i = 0; i < array.length; i++){ calledInLoop(array[i]); }; } myArray = ['dog', 'bird', 'cat', 'gopher'];
console.log(loopThrough(myArray)); returns each element on its own console.log line but then returns undefined. Why is this?