Thursday, July 30, 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

REST API best practices

February 23, 2022 beroza

Return the next higher prime number

February 11, 2022 beroza

Find if the sum of two integers is equal to the given value

February 10, 2022 beroza

How to solve “Add Expires headers” of GTMatrix for websites?

January 5, 2020 beroza

Is there a print_r or var_dump equivalent in Ruby on Rails?

May 27, 2020 beroza

Command design pattern

February 2, 2025 beroza

Type ‘null’ is not assignable to type ‘T’

December 1, 2021 beroza

What is microservice? What are the properties of microservice?

June 18, 2020 beroza

What are the main differences between ApplicationContext and BeanFactory?

November 1, 2025 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.