Sunday, October 11, 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

React state update is not re-rendering the UI

December 21, 2020 beroza

Uncaught Error: Invariant Violation: Element type is invalid: expected a string or a class/function but got: object

December 16, 2021 beroza

MySQL ERROR 1045 (28000): Access denied for user ‘mentor’@’localhost’

February 3, 2020 beroza

Keyword “this” is immutable in JavaScript

February 25, 2019 beroza

How to stop adding, modifying and deleting an object’s properties?

August 7, 2021 beroza

ReferenceError: localStorage is not defined

April 10, 2021 beroza

Strategy Design Pattern

December 24, 2022 beroza

Write a JavaScript curry function to add n numbers

April 23, 2022 beroza

Should we write a lot of code inside finally block?

June 22, 2023 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.