Created
June 24, 2017 23:40
-
-
Save viniazvd/ae60021a736ceb4c77633d21c4bb533e to your computer and use it in GitHub Desktop.
This file contains 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 array = [7, 9, 11, 13, 15] | |
const matchTwoNumbers = 20 | |
const match = ( total, num, index, arr ) => { | |
let sum = total + num | |
let indexs = [] | |
// console.log(total, num, sum, index, arr ) | |
if ( sum == matchTwoNumbers ) | |
indexs.push[ index ] | |
else | |
//? | |
return sum | |
} | |
const result = array.reduce( match, 0 ) | |
console.log( result ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment