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?
thanks
Your code so far
function splitify(str) {
// Only change code below this line
console.log(str.split(/[^\w]/));
// Only change code above this line
}
splitify("Hello World,I-am code");
splitify("Earth-is-our home");
splitify("This.is.a-sentence");
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: