<aside> ⏰ Duration: You should not spend more than 2 hours on this problem. Time estimation is for internship roles, if you are a software professional you should spend significantly less time.
</aside>
Provide 3 unique implementations of the following function in JavaScript.
Input: n
- any integer
Assuming this input will always produce a result lesser than Number.MAX_SAFE_INTEGER
.
Output: return
- summation to n
, i.e. sum_to_n(5) === 1 + 2 + 3 + 4 + 5 === 15
.
var sum_to_n_a = function(n) {
// your code here
};
var sum_to_n_b = function(n) {
// your code here
};
var sum_to_n_c = function(n) {
// your code here
};