What I learned from writing six functions that all did the same thing
Jackson Bates
1.3K37

I have written an ES6 recursive function, gonna try to write some tests and check the performance!

function sum_divisors_3_or_5(index, sum = 0) {
 index — ;
 if(index > 2) {
 let x = index % 3 == 0 || index % 5 == 0 ? index : 0;
 return sum_divisors_3_or_5(index, sum + x);
 } else {
 return sum;
 }
}

http://www.es6fiddle.net/ivsmuz18/