+ 1
Write a code to count the spaces in a string
I.e if I write "my name is" then result should be 2
2 odpowiedzi
+ 4
var str= "my name is";
var a = str.match(/\s/g).length;
alert(a);
+ 3
var str = 'my name is';
str.split(' ').length-1; // output 2
I.e if I write "my name is" then result should be 2