Advertisement
kstoyanov

03. Same Numbers js advanced

Sep 16th, 2020
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(arg) {
  2.   const numArr = arg.toString().split('').map(Number);
  3.   const firstDig = numArr[0];
  4.   const isSame = numArr.every((num) => num === firstDig);
  5.   const result = numArr.reduce((agrr, curnV) => agrr + curnV, 0);
  6.  
  7.   console.log(isSame);
  8.   console.log(result);
  9. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement