Link to home
Start Free TrialLog in
Avatar of a_tirtha
a_tirtha

asked on

Calculate the no of alphabets in a string

Given a string, how is the total number of alphabets and numerics contained, calculated using javascript?

var strline ="Testing123";
var numbers=0;
var alphas =0;

for (var i=0; i<strline.length; i++)
{
    if(strline.charAT(i) == number)numbers++;
    if(strline.charAT(i) == alphabet)alphas ++;

}

alert ("Contains " + numbers + " number and "+ alphas + " alphabet characters");

Please advice.
ASKER CERTIFIED SOLUTION
Avatar of sajuks
sajuks

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial