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 :: react validate 
Javascript :: setting up a react environment 
Javascript :: callbacks in jquery 
Javascript :: add array type to sequelize migration 
Javascript :: for of loop in javascript 
Javascript :: how does an if statement work 
Javascript :: add a slash to string in javascript 
Javascript :: js if 
Javascript :: fastify testing 
Javascript :: js remove several elements from array 
Javascript :: dark mode javascript 
Javascript :: fetch not working javascript 
Javascript :: got back to start of for loop js 
Javascript :: LEAODE MAJE 
Javascript :: unity overlap box 
Javascript :: what would (int) (Math.random()) output 
Javascript :: macam macam looping javascript 
Javascript :: tablica w javascript 
Javascript :: "npm supertest 
Python :: months list python 
Python :: discord bot status python 
Python :: python install matplotlib 
Python :: legend size matplotlib 
Python :: python datetime tomorrow date 
Python :: maximize window in selenium 
Python :: python change plot transparency 
Python :: pip pickle 
Python :: pandas set options 
Python :: running selenium on google colab 
Python :: take space separated int input in python 
ADD CONTENT
Topic
Content
Source link
Name
2+8 =