count spaces in string js code example
Example 1: js find space in string
if(str.indexOf(' ') >= 0){
console.log("contains spaces");
}
Example 2: count the number of spacesinto a string javascript
var my_string = "John Doe's iPhone6";
var spaceCount = (my_string.split(" ").length - 1);
console.log(spaceCount)