Skip to content

Instantly share code, notes, and snippets.

@nataliemarleny
Created January 15, 2019 17:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nataliemarleny/ebfb1116d04bc7367e4ccd212dc02763 to your computer and use it in GitHub Desktop.
Save nataliemarleny/ebfb1116d04bc7367e4ccd212dc02763 to your computer and use it in GitHub Desktop.
cross-add
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