I am having a scoping issue when iterating over an object in coffeescirpt. I had a similar issue with looping over an array, but was able to solve that using forEach, which gave me a new scope for each loop. Now I am having a similar issue except instead of an array, this time I am using an object/dictionary. The problem is that when looping over the object, the last console.log
always returns data for the last person in the object, for all the the people. I think this is a scoping issue but I am not sure how to solve it.
for name, data of people
console.log name
lookup name, (err, other_data) ->
console.log data # this always returns the data for the last person