Saturday, April 4, 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

List.of() vs Collections.emptyList() which one is better?

July 24, 2020 beroza

Query in-stock products WooCommerce WordPress.

January 4, 2020 beroza

String.equals vs == operator in Java

November 13, 2019 beroza

What is spread syntax? Explain with example

May 11, 2019 beroza

What is state in ReactJS and where to initialize it?

April 19, 2019 beroza

How to uninstall android studio from Ubuntu 16.04 or 18.04?

December 4, 2018 beroza

Why LinkedList is important?

December 25, 2022 beroza

How to catch all JavaScript errors and send to server?

July 26, 2021 beroza

Uncaught TypeError: iterable is not iterable

May 21, 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.