Created
January 15, 2019 17:18
-
-
Save nataliemarleny/ebfb1116d04bc7367e4ccd212dc02763 to your computer and use it in GitHub Desktop.
cross-add
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
function crossAdd(input) { | |
let answer = []; | |
for (let i = 0; i < input.length; i += 1) { | |
let goingUp = input[i]; | |
let goingDown = input(input.length-1-i]; | |
answer.push(goingUp + goingDown); | |
} | |
return answer; | |
} | |
// input [1, 2, 3] | |
// output [4, 4, 4] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment