I have created a user array, how could I remove name’s spacing in the user array using for loop?

Viewed 29

Following is an example with only three users

const users = [ { name: "Alan Brown", initial: "AB”, }, { name: "Judy White", initial: "JW" }, { name: "Bruce Lee", initial: "bl" } ]

Thank you so much for helping out!

1 Answers
const users = [ { name: "Alan Brown", initial: "AB", }, { name: "Judy White", initial: "JW" }, { name: "Bruce Lee", initial: "bl" } ]


users.forEach(({ name }) => console.log(`${name}`));

See here first error was with initial: "AB”, you have to write it as initial: "AB",

then here is the snippet of its working[enter image description here][1]

[1]: https://i.stack.imgur.com/d0RAY.png Here is the working

Related