About 37,400,000 results
Open links in new tab
  1. javascript - Return sum of all arguments passed to function

    Dec 5, 2016 · Use Array.prototype.slice.call to convert arguments into array, and use reduce to sum up numbers. function sum(){ var total = …

  2. JavaScript Program to Add Two Numbers - GeeksforGeeks

    May 8, 2024 · Adding two numbers using an arrow function in JavaScript involves creating a concise function syntax that adds parameters and returns the sum. Syntax: let addition = (a, b) …

  3. JavaScript: 6 Ways to Calculate the Sum of an Array

    Feb 19, 2023 · This practical, succinct article walks you through three examples that use three different approaches to find the sum of all elements of a given array in Javascript (suppose …

  4. Sum two numbers - JSCHALLENGER

    Write a function that takes two numbers (a and b) as argument. Sum a and b. Return the result.

  5. Addition of two numbers in JavaScript using functions - EyeHunts

    Feb 10, 2021 · Create a simple function with parameters and use the + operator to add two or more numbers in the JavaScript function. This code snippet is used to find the sum of two …

  6. javascript - How to find the sum of an array of numbers - Stack Overflow

    Dec 13, 2014 · Array.prototype.reduce can be used to iterate through the array, adding the current element value to the sum of the previous element values. [1, 2, 3, 4].reduce((a, b) => a …

  7. Javascript Functions - Javascript Cheatsheet

    add is a function that takes two parameters, a and b, and returns their sum. The return statement specifies that the sum of a and b should be returned to the function caller. When you call this …

  8. JavaScript Return Statement - GeeksforGeeks

    Feb 7, 2025 · In this example, the return statement returns the sum of a and b to the caller. If a return statement is used without a value, the function will return undefined. You can return …

  9. What is Sum Function in JavaScript? | Syntax, Usage & Examples

    Aug 3, 2023 · The sum function in Javascript is a tool that calculates the sum of the numbers or elements within an array. Additionally, it makes multiple arguments, adds them together, and …

  10. JavaScript: Calculate the sum of values in an array

    Mar 1, 2025 · Write a JavaScript function that iterates through an array with a loop to calculate the total sum of its values. Write a JavaScript function that uses the reduce() method to sum array …

Refresh