-
Code const getIDS = n => [n].reduce((r, x) => r + +x, 0)
Test Cases Test.assertEquals(getIDS('1345'), 13); Test.assertEquals(getIDS('1'), 1); Test.assertEquals(getIDS('12'), 3); Test.assertEquals(getIDS('110'), 2); Test.assertEquals(getIDS('011'), 2);
Output:
-
Code const getIDS = n => [...n].reduce((r, x) => r + Number(x), 0);- const getIDS = n => [...n].reduce((r, x) => r + +x, 0)
- All
- {{group.name}} ({{group.count}})
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}