Tell us what’s happening:
Following in my code but I am getting undefined, why? the way I understand it, the function body has a variable name fragment
which has an array, next there is another variable name sentence
which is equal to the mix of an array and spread, and on the third line, I m return
ing that element.
Outside of the function
I am console.log
the function
, but why is it undefined, I do have a return in the function
body
**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 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36
Challenge: Basic Data Structures - Combine Arrays with the Spread Operator
Link to the challenge: