Functional Programming: Split a String into an Array Using the split Method: code does not pass

Tell us what’s happening:
Hello! The below code gives the following output:

[ ‘Hello’, ‘World’, ‘I’, ‘am’, ‘code’ ]
[ ‘Earth’, ‘is’, ‘our’, ‘home’ ]
[ ‘This’, ‘is’, ‘a’, ‘sentence’ ]

But it does not pass the challenge. Can anyone tell me why?


Your code so far

function splitify(str) {
// Only change code below this line

// Only change code above this line
splitify("Hello World,I-am code");
splitify("Earth-is-our home");

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36.

Challenge: Split a String into an Array Using the split Method

Link to the challenge:

You forgot to add a return statement in your splitify function without that it just splits and returns nothing.

return str.split(/[^\w]/);

Figured out my own error - had to remove the console.log statement. oops!

@mayankverma, thanks!