I am facing an issue with the following code snippet:
this.array1 = this.array1.map(a => (a.name = "Harold"));
It seems like there is a syntax error, and I can't figure out why. My intention is to set the "name"
property of every object in array1
to Harold
.
The structure of the array is as follows:
array1 = [
{
name: "ashley",
last: "bob"
},
{
name: "tiny",
last: "tot"
}
]
The error message I receive is:
Arrow function should not return assignment
The desired outcome is an array that looks like:
array1 = [
{
name: "Harold",
last: "bob"
},
{
name: "Harold",
last: "tot"
}
]