Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

adding numbers in an array javascript

console.log(
  [].reduce((a, b) => a + b)
)
Comment

how to add numbers in an array in javascript

// how to add numbers in an array in javascript
let number = [10, 20, 40];
let result = number.reduce((a, b) => a + b);
console.log(result); // 70
Comment

add numbers in array

const years = [1, 2, 3, 4]
let total = 0;
for (let i = 0; i < years.length; i++) {

    total += years[i]

}

console.log(total)

//answer willl be 10
Comment

add numbers from array nodejs

//these are the values//
var values = [
	'1',
  	'2'
]
//makes a variable named total, adding together the values
var total = values[0] + values[1]

//prints out the variable named total
console.log(total);
Comment

PREVIOUS NEXT
Code Example
Javascript :: trigger play video jquery 
Javascript :: convert file to blob javascript 
Javascript :: get element by click 
Javascript :: add active class to li onclick react 
Javascript :: jquery on focus 
Javascript :: convert svg to base64 javascript 
Javascript :: linked list javascript 
Javascript :: truncate text javascript 
Javascript :: js math.random 
Javascript :: javascript to remove last character in string 
Javascript :: js for in 10 
Javascript :: json multiple records 
Javascript :: how to run bare react-native project 
Javascript :: install bcrypt 
Javascript :: get parameters from url 
Javascript :: basic server on node.js 
Javascript :: javascript early break reduce() method 
Javascript :: vowel 
Javascript :: express request body undefined 
Javascript :: select element as role in jquery 
Javascript :: regexp constructor javascript 
Javascript :: js validate phone number 
Javascript :: embed example discord.js 
Javascript :: react js onclick call two functions 
Javascript :: how to remove an element javascript html 
Javascript :: react refresh 404 error 
Javascript :: javascript random 4 digit number 
Javascript :: wait function in javascript 
Javascript :: jquery table each rows with class 
Javascript :: javascript how to check if array is empty 
ADD CONTENT
Topic
Content
Source link
Name
5+1 =