Skip to content

Instantly share code, notes, and snippets.

@Seminioni
Created September 1, 2017 08:46
Show Gist options
  • Save Seminioni/4c9c658942b18c72f45a93684ad199f0 to your computer and use it in GitHub Desktop.
Save Seminioni/4c9c658942b18c72f45a93684ad199f0 to your computer and use it in GitHub Desktop.
const number = '+7(222)444-55-66'
const arr = Array.from(number)
.filter(el => {
return /\d/.test(el)
})
.reduce((num, acc) => {
return +num + +acc;
}, 0)
console.log(arr)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment