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 :: click anchor tag using jquery 
Javascript :: js array two dimensional 
Javascript :: check if the document is ready js 
Javascript :: angular http put 
Javascript :: firestore add document 
Javascript :: reduce() break 
Javascript :: reversed array loop 
Javascript :: iiee javascript 
Javascript :: check if url is http or https javascript 
Javascript :: how to change user password firebase 
Javascript :: js named parameters 
Javascript :: react useeffect avoid initial render 
Javascript :: js events 
Javascript :: convert utc string to date format of mm dd/mm/yyyy in javascript 
Javascript :: javascript set to array 
Javascript :: javascript isalphanumeric 
Javascript :: deleting key of json object 
Javascript :: set js 
Javascript :: get name of class javascript 
Javascript :: queryselector name attribute 
Javascript :: how to convert celsius to fahrenheit in javascript 
Javascript :: mui get theme color in component 
Javascript :: Error: While trying to resolve module `@apollo/client` from file 
Javascript :: javascript class extends 
Javascript :: install react router dom with npm 
Javascript :: regular expression to remove underscore from a string javascript 
Javascript :: select dropdown value using jquery 
Javascript :: react js get screen size 
Javascript :: download json file react 
Javascript :: boolean constructor js 
ADD CONTENT
Topic
Content
Source link
Name
1+7 =