Skip to content

Instantly share code, notes, and snippets.

@funador
Last active July 25, 2018 21:28
Show Gist options
  • Save funador/df8e25749bee7116eeaf8795727e9202 to your computer and use it in GitHub Desktop.
Save funador/df8e25749bee7116eeaf8795727e9202 to your computer and use it in GitHub Desktop.
const arrToManipulate = [3, 5, 9, 2]
const atIndex2 = arr => {
let total = 1
const retArr = []
for(let i = 0; i < arr.length; i++) {
total *= arr[i]
}
for(let j = 0; j < arr.length; j++) {
retArr.push(total / arr[j])
}
return retArr
}
atIndex2(arrToManipulate) // [90, 54, 30, 135]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment