Friday, January 30, 2026
Latest:
  • 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?
  • How Spring framework resolves circular dependencies?
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

What is useRef in React? What are the use cases of useRef?

August 14, 2021 beroza

ERROR: Permission to repository.git denied to username. fatal: The remote end hung up unexpectedly

August 31, 2019 beroza

Query posts with featured image in WordPress.

January 4, 2020 beroza

What does /dev/sda means in Linux?

January 4, 2019 beroza

CSS special selectors

August 26, 2021 beroza

Refresh meta tag not working properly

January 1, 2019 beroza

Write a Program to Find Number of Unequal Triplets in Array

January 16, 2023 beroza

What is state design pattern?

August 4, 2020 beroza

Uncaught ReferenceError: $ is not defined

August 6, 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.