count the number of spacesinto a string javascript

JavaScript
var my_string = "John Doe's iPhone6";
var spaceCount = (my_string.split(" ").length - 1);
console.log(spaceCount)
string.concat(value1, value2, ... value_n);
Source

Also in JavaScript: