Skip to content

Instantly share code, notes, and snippets.

@viniazvd
Created June 24, 2017 23:40
Show Gist options
  • Save viniazvd/ae60021a736ceb4c77633d21c4bb533e to your computer and use it in GitHub Desktop.
Save viniazvd/ae60021a736ceb4c77633d21c4bb533e to your computer and use it in GitHub Desktop.
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