Your issue is you're not defining name locally, so it's a global variable and just ends up filled with the last value you set it to. If you change:
name
data = getDataStreams(); Object.keys(data).forEach(function(k){ name = data[k].description.split(" / ")[0];
to
data = getDataStreams(); Object.keys(data).forEach(function(k){ var name = data[k].description.split(" / ")[0];
Then name ends up defined locally in the function defined inside forEach, so each key in data has its own version of name set.
That's exactly it, thank you!
@Gordon started
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Your issue is you're not defining
name
locally, so it's a global variable and just ends up filled with the last value you set it to. If you change:to
Then
name
ends up defined locally in the function defined inside forEach, so each key in data has its own version ofname
set.