After reading this SO post I am still having issues looping over my data structure:
users:
{
'names': ['john','chris'],
'addresses': ['10 king street', '20 king street'],
}
The loop:
for (const prop in this.payload) {
console.log(prop); //names
for (const item of prop) {
console.log(item); //n //a //m //e //s
}
}
It appears to be outputting the letters of the key "names", then doing the same for the other keys.
Why? The expected output is:
names
john
chris
addresses
10 king street
20 king street