Files
Randell Dawson 1494a50123 fix(guide): restructure curriculum guide articles (#36501)
* fix: restructure certifications guide articles
* fix: added 3 dashes line before prob expl
* fix: added 3 dashes line before hints
* fix: added 3 dashes line before solutions
2019-07-24 13:29:27 +05:30

846 B

title
title
Split a String into an Array Using the split Method

Split a String into an Array Using the split Method


Problem Explanation

Simply split the string to create a new array of words.

A simple regular expression can be used to achieve this result.

/\W/ Matches any non-word character. This includes spaces and punctuation, but not underscores. It's equivalent to /[^A-Za-z0-9_]/. For more information about Regular Expressions, see the official MDN Documentation.


Solutions

Solution 1 (Click to Show/Hide)
function splitify(str) {
  // Add your code below this line
  return str.split(/\W/);
  // Add your code above this line
}
splitify("Hello World,I-am code");