Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function sumOfNumbers(input) {
- let digitAsText = "" + input[0];
- let sum = 0;
- for (let index = 0; index < digitAsText.length; index++) {
- let n = Number(digitAsText.charAt(index));
- sum += n;
- }
- console.log(`The sum of the digits is:${sum}`);
- }
- sumOfNumbers(["1234"])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement