Thursday, October 29, 2026
Latest:
  • Präsentation für b1
  • Verb “werden” Konjugation
  • In German, verb sein (to be) Konjunktion
  • Wichtige wörter für B1 prüfung
  • What are the main differences between ApplicationContext and BeanFactory?
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 run a spring boot application from command line?

December 4, 2019 beroza

Difference between export const vs. export default in React

December 12, 2020 beroza

How to execute a function on load, resize and scroll event in jQuery?

September 16, 2019 beroza

Positions of Large Groups

December 27, 2022 beroza

Minimum Changes To Make Alternating Binary String

January 11, 2023 beroza

AWS IAM error : ‘Your authentication information is incorrect. Please try again’

October 25, 2019 beroza

Consider static factory methods instead of constructors

January 23, 2020 beroza

Find the missing number in the array using JavaScript.

February 10, 2022 beroza

How to quick start reactjs application using jenkinsX?

February 19, 2020 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.