Sum a range of numbers/javascript

Donovan
2 min readAug 27, 2021

Looking to find the sum of all numbers between two integers? I got you.

I love loops. For this problem I have used two “for” loops to solve the problem although there, as always, has to be a better way.

We will first need to create a variable, “nums”, that points to an empty array that we can push numbers to. After we create this variable we will use the first “for” loop to push all numbers between the two values into that array.

Assuming the two values were given to us as arguments we will call them “a’ and “b”. The…

--

--

Donovan

Learning. Puttin up shots in Angular and Java and Python and anything else I get my hands on. Sights set on becoming a gainfully employed developer.