Basic data structures: Combine arrays with spread

Tell us what’s happening:

I came up with the exact solution that was given in the hints but I can’t run the tests because of this: “TypeError: Cannot read property ‘presets’ of undefined.”

Your code so far


function spreadOut() {
let fragment = ['to', 'code'];
let sentence = ["learning", ...fragment, "is", "fun"]; // Change this line
return sentence;
}

console.log(spreadOut());

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.105 Safari/537.36.

Challenge: Combine Arrays with the Spread Operator

Link to the challenge:

I just encountered the same error in the next exercise, so I switched from Chrome to Firefox. I don’t get that error in Firefox.

1 Like

Your solution works for me, both in Firefox and Chromium.

It’s always a good idea to have two browsers installed and use the other one when stuff doesn’t work as expected.

Hello there,

Just something to note: Often, campers struggle with certain challenges, because a browser extension affects the JavaScript running the page.

Hi, the tests have worked fine for me in Chrome until today, and I’ve added no new browser extensions.

I believe the error is related to babel (possibly from a stale cache).

Can you try clearing the cache in Chrome?

Or you can try running the challenge with the cache disabled (F12 > Network tab > Check “Disable cache”) keep the console open and run the tests.

Well , for whatever reason, when I tried it again using Chrome, it worked with no issues. I don’t know if that’s because I had already submitting the correct answers in Firefox. But things seem to work now. They will work better once I understand the for in loop thing :slight_smile: