Skip to content
Advertisement

Trying to sum numbers between numbers more efficiently

TLDR: Need to make code below more efficient.

I’m trying to solve a coding challenge that requires I sum all numbers between two numbers. My code shown below is passing the tests but is taking too long to run, causing me to fail due to a time out.

Is there any way to rewrite this to do the same thing in less time?

EDIT: solved, thank you so much for your solutions

JavaScript

Advertisement

Answer

Maybe this?

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement