yourStr.split('')
/* split methods splits string object into array of strings
and join method changes element of array into a string */
const name= "Shirshak Kandel"
const nameWithDash=name.split(" ").join("-")
console.log(nameWithDash);//Shirshak-kandel
const splitText = (string) => {
const newText = string
.split(/((?:w+ ){1})/g)
.filter(Boolean)
.join("
");
return newText
};
console.log(splitText("Hello, world"));
//Hello,
//world
const string = "this is the array that we want to split";
var splittedString = string.split(" ") //place the separator as a parameter
/* splittedString:
* ['this', 'is', 'the', 'array', 'that', 'we', 'want', 'to', 'split']
*/
var myArray = myString.split(",");
var myArray = myString.split(" ");