Hello campers,
I am trying to solve this exercise: Split a String into an Array Using the split Method
Link to the challenge:
This is my code. I am almost there!
function splitify(str) {
// Only change code below this line
let newStr = str;
let splitedStr = newStr.split(/\s|,|-/);
return splitedStr
// Only change code above this line
}
console.log(splitify("Hello World,I-am code"));
console.log(splitify("This.is.a-sentence"));
My browser information:
User Agent is: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0
.
Unfortunately, my regex code is not passing on this final test:
splitify("This.is.a-sentence") should return ["This", "is", "a", "sentence"]
The This.is.a is the problem. I know other ways to solve this. However, I would like to build upon this regex: split(/\s|,|-/)
Is it possible to solve the challenge with something on top of this?
Thanks in advance.
Best,
Pedro