Sum of Digits in JavaScript

Write a program to accept a no. from user and display Sum of Digits.
(example: 214= 2+1+4 =  7)

Enter a Number:

JavaScript Code:

function find()
 var sum=0;
    var no=parseInt(frm.txt1.value);
    alert("Sum of digits  "+sum);    
<form name="frm">

Enter a Number:<input name="txt1" type="text" />
<input name="b1" onclick="find();" type="button" value="display" /></form>

1 comment:

Thanks for visiting my Blog!

Have a Question ? Need Help in College Assignments, Need Code that is not available here? Just leave a comment & get your code instantly.

Tips to Enhance Your Blog