Monday, June 8, 2026
Latest:
  • In German, verb sein (to be) Konjunktion
  • Wichtige wörter für B1 prüfung
  • What are the main differences between ApplicationContext and BeanFactory?
  • German B1 Word list
  • How does Lazy annotation work in Spring?
Upokary

Upokary

Quality information

  • Health
  • Life
  • Fashion
  • Food
  • Code
  • English
  • বাংলা
Technology 

Calculate the sum of numbers from 1 to n using recursion

Published: June 17, 2023 code, program, programming, programming tips, recursion
(function(){
    // Calculate the sum of numbers from 1 to n using recursion.

    const getSum = (arr) => {
       if (arr.length < 1) {
          return 0;
       }

       return arr.pop() + getSum(arr);
    };
 
    const a = [1, 2, 3, 5];
    console.log(getSum(a))
})();

You May Also Like

How to get last Monday or last Friday or any last day in JavaScript?

April 20, 2021 beroza

What are the differences between IP address 0.0.0.0 and 127.0.0.1?

December 4, 2019 beroza

JavaScript “let” and “var” related interview questions

March 19, 2019 beroza

ReactJS hook related interview questions

July 10, 2019 beroza

How to do a HTTP API call in ruby on rails?

July 16, 2020 beroza

How to install free SSL to apache with lets encrypt on ubuntu?

November 6, 2019 beroza

How to use fetch with Async, Await in JavaScript?

March 5, 2021 beroza

The Ruby version you are trying to install does not exist on this stack

June 1, 2020 beroza

Useful Java basic tips for developers

February 26, 2019 beroza

Why Upokary?

Upokary.com is a useful application in everyday life. It provides very handy information regarding every aspect of life. Each and every tip of upokary.com is meant to make life better.

Upokary tools

  • Youtube thumbnail
  • Youtube video downloader

Useful Links

  • Handy code
  • Technology
  • People
  • Programming
  • Quote
  • Travel
  • WordPress
  • IELTS
  • Kids

Pages

  • Sitemap
  • Privacy policy
  • About us
  • Contact us

Support

For any kind of query or question please drop a message in the following email: upokary@gmail.com
Copyright © 2026 Upokary. All rights reserved.