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?

es6

11/26/2019 2:23:27 PM

Stuart Peel

1 Answer

New 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