Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Latest commit

 

History

History
 
 

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

README.md

Exercise 09 - sumAll

Implement a function that takes 2 positive integers and returns the sum of every integer between (and including) them:

sumAll(1, 4) // returns the sum of 1 + 2 + 3 + 4 which is 10

Hints

  • How will you ensure you're summing all integers within the correct range, no matter the order of the inputs?

  • Think about your sum's starting value. Then, how can you make sure every single number from the smaller input to the larger one (including both) gets added to it?