Advertisement
Guest User

Untitled

a guest
Sep 26th, 2017
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.24 KB | None | 0 0
  1. function getSum(s) {
  2. return s.match(new RegExp(/\d+/, 'g'))
  3. .map(function (t) { return t & 1 ? Math.pow(t, 2) : 0 })
  4. .reduce(function (total, n) {
  5. return total + n;
  6. })
  7. }
  8.  
  9. console.log(getSum("ab2v9bc13j5jf4jv21"));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement