+ 1

Counting of comas

hello what is the code/script for counting the comas in a given lines a,b,c,d,e,f,g,h,I,j I want to count number of comas in the above line. what is the scrip(JavaScript) to count the comas

1st Dec 2017, 10:36 AM
ADITYA AVADHANI M.L
ADITYA AVADHANI M.L - avatar
3 odpowiedzi
+ 8
JavaScript: alert(prompt("").split(",").length - 1);
1st Dec 2017, 12:38 PM
Krishna Teja Yeluripati
Krishna Teja Yeluripati - avatar
+ 2
try this... var i="a,b,c,d,e"; alert(i.split(',').length-1);
1st Dec 2017, 11:20 AM
Md. Nafis Ul Haque Shifat
Md. Nafis Ul Haque Shifat - avatar
0
console.log('a,b,c,d,e,f,g,h,I,j'.match(/,/g).length);
1st Dec 2017, 12:23 PM
richard