how do I use Javascript to turn this list:
var array = ["no yes", "maybe certainly"];
into this one:
var array2 = ["no", "yes", "maybe", "certainly"]
It's better to use regex here, if there are chances of multiple spaces in the array elements.
var array = [" no yes ", " maybe certainly "];
var array2 = array.join('').match(/\S+/g);
document.write(array2);
console.log(array2);
split more faster than matchvar array = ["no yes", "maybe certainly"]
answer = converfunction(array);
function converfunction(array){
return array.toString().replace(',',' ' ).split(' ')
}
var array = [" no yes ", " maybe certainly "];