What is wrong with this code in: Spread in object literals tutorial: | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What is wrong with this code in: Spread in object literals tutorial:

When I click the 'Try It' button for the following code: const obj1 = { foo: 'bar', x: 42 }; const obj2 = { foo: 'baz', y: 5 }; const clonedObj = { ...obj1 }; // { foo: "bar", x: 42 } const mergedObj = { ...obj1, ...obj2 }; // { foo: "baz", x: 42, y: 5 } There is an 'unrecoverable syntax error' with the line: const clonedObj = { ...obj1 }; // { foo: "bar", x: 42 } 'Expected '}' to match '{' and instead saw '...'. 'Missing semicolon. Can anyone see the problem and tell me how to fix it please?

26th Nov 2019, 2:23 PM
Stuart Peel
1 Answer
0
I see no problem with the code. In fact I went and tried the code in the lesson from the JS tutorial and it worked. Also copied the code from your question, tried it in the editor and it also worked fine. https://code.sololearn.com/WoOU3og84QWt/?ref=app
27th Nov 2019, 4:25 PM
Ernesto García Xenes
Ernesto García Xenes - avatar