Created
December 15, 2020 08:13
-
-
Save onejohi/7a9634ec2bd3bd3fd0b029eef979fbc0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const arrayOfNumbers = ['BOB778','KEK7899','FOR4442','KIMP889']; | |
const numberValues = arrayOfNumbers.map(item => item.match(/\d+/)[0]); | |
const sumOfNumbers = numberValues.reduce((total, num) => Number(total) + Number(num)); | |
// sumOfNumbers = 14008 [778 + 7899 + 4442 + 889] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment