Browse By

How to Split String, count element and implement loop in Jquery?

Spread the love

Split Sting with function :


Count element:


Complete code is give below.

<script src=""></script>

 	var string = 'Harry,John,Clark,Peter,Rohn,Alice';
	var nameArr = string.split(',');
	for(var i = 0; i < nameArr.length; i++)

explain code :

string.split(‘,’) is used for spliting string into arrray which can be achieve by using single value like alert(nameArr[1])

nameArr.length is userd for counting Array length

for(var i = 0; i < nameArr.length; i++) is used for looking the variable till end of the length of string.



Leave a Reply

Your email address will not be published. Required fields are marked *