The data engineer in my team wrote a program to pull data from a certain API, and, well... it doesn't work. I've been tasked with fixing it, so I've been going through and now I'm trying to figure out what this chunk of code does.
async function asyncForEach(array, callback) {
const isArray = Array.isArray(array)
for (const key in array) {
if (isArray ? key < array.length : array.hasOwnProperty(key)) {
const val = array[key]
await callback(val, key)
}
}
}
It seems like it checks if an item is an array, and then something do do with the value of the array key...?