Answer: Use the JavaScript split()
method
If you want to explode or split a string from a certain character or separator you can use the JavaScript split()
method. The following example will show you how to split a string at each blank space. The returned value will be an array, containing the splitted values.
var myStr = "The quick brown fox jumps over the lazy dog.";
var strArray = myStr.split(" ");
// Display array values on page
for(var i = 0; i < strArray.length; i++){
document.write("" + strArray[i] + "
");
}