Created
August 27, 2020 05:50
-
-
Save RomaSto/032197c202f08d8f15b427cd022b635f to your computer and use it in GitHub Desktop.
This file contains hidden or 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 sumTo(n) { | |
return n * (n + 1) / 2; | |
} | |
function solution(A) { | |
// write your code in JavaScript (Node.js 8.9.4) | |
let arraySum = A.reduce(function(acc, el) { return acc + el; }, 0); | |
let sum =sumTo(A.length+1) | |
return sum - arraySum | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment