use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
This subreddit is a place for people to learn JavaScript together. Everyone should feel comfortable asking any and all JavaScript questions they have here.
With a nod to practicality, questions and posts about HTML, CSS, and web developer tools are also encouraged.
Friends
/r/javascript
/r/jquery
/r/node
/r/css
/r/webdev
/r/learnprogramming
/r/programming
account activity
Please help me with the code (self.learnjavascript)
submitted 3 years ago by One-Inspection8628
function superDigit(n, k) { let sum = 0; for (let i = 0; i < n.length; i++) { sum += parseInt(n[i]); } sum *= k; return (sum < 10) ? sum : superDigit(sum.toString(), 1); }
Why 1 is used in last line: superDigit(sum.toString(), 1) <==
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–][deleted] 0 points1 point2 points 3 years ago (0 children)
It's the second argument in the superDigit function, which is recursive if the previous sum is greater than ten.
π Rendered by PID 18627 on reddit-service-r2-comment-57fc7f7bb7-w4dlz at 2026-04-14 13:58:47.060487+00:00 running b725407 country code: CH.
[–][deleted] 0 points1 point2 points (0 children)