actionscript 3 - How to count numbers in string -


i have string contains numbers this: 2243. need total of these numbers. using example numbers in string converted integers , i'd able this: 2+2+4+3 = 11.

not having coded in quite while find myself bit stumped on (probably) quite easy task.

all appreciated!

you can :

var number:string = "2243";   // represents original string number var result:int = 0;  (var i:int = 0; < number.length; i++) {    result += parseint(number.charat(i), 10); }  // result var contain sum 

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -