105k views
3 votes
How do you fix the syntax error that results from running this code?

const person =(firstName, lastName) =>
{
first: firstName,
last: lastName
}
(person("Jill", "Wolson"))

1 Answer

5 votes

Final answer:

To fix the syntax error, encapsulate the object properties in parentheses and return the object from the arrow function.

Step-by-step explanation:

To fix the syntax error in the given code, you need to make two changes:

Here is the corrected code:

const person = (firstName, lastName) => ({ first: firstName, last: lastName });

Now, you can call the function correctly:

person('Jill', 'Wolson');
User Amos
by
8.9k points