Map to objects
You have an array of user objects, each one has name, surname and id.
Write the code to create another array from it, of objects with id and fullName, where fullName is generated from name and surname.
For instance:
So, actually you need to map one array of objects to another. Try using => here. There’s a small catch.
Please note that in the arrow functions we need to use additional brackets.
We can’t write like this:
As we remember, there are two arrow functions: without body value => expr and with body value => {...}.
Here JavaScript would treat { as the start of function body, not the start of the object. The workaround is to wrap them in the “normal” brackets:
Now fine.