Nicolas O
Nicolas O

Reputation: 151

If within map function: Getting unexpected error

I get an unexpected error while following some code examples which I found online. I assume I have made some mistake, but comparing to other examples here, I cannot find the mistake. I am trying to include an if function within a map function:

const compProfileRemoveHandler = compProfileId => {
    todoList.map(profile =>(
     if (profile.id !== compProfileId) {some code}
))};

Does anyone know why I get the following error: "Parsing error: Unexpected token" (and the 'if' is marked under the statement).

Many thanks for your help!

Upvotes: 0

Views: 469

Answers (1)

Roy.B
Roy.B

Reputation: 2106

try this:

const compProfileRemoveHandler = compProfileId => {
    todoList.map(profile => {
     if (profile.id !== compProfileId) {some code}
} )};

Upvotes: 7

Related Questions