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 :: how to remove class in all siblings javascript 
Javascript :: js substring first 4 numbwe 
Javascript :: react js date ago 
Javascript :: js array comprehension 
Javascript :: object traversal javascript 
Javascript :: javascript get day 
Javascript :: forin js 
Javascript :: continuous scrolling js 
Javascript :: react lazy import non default 
Javascript :: how to get thumbnail image from video file in javascript 
Javascript :: create app with a specific react version 
Javascript :: document.append 
Javascript :: add multiple class from array javascript 
Javascript :: jq each loop 
Javascript :: change css with javascript 
Javascript :: copying object javascript 
Javascript :: while vs do while javascript 
Javascript :: react router dom private route 
Javascript :: javascript Get Key/Values of Map 
Javascript :: how to save and use item from local storage javascript 
Javascript :: get value for radio button in jquery label 
Javascript :: react native counter 
Javascript :: How to get current time zone in javascript 
Javascript :: define an unsigned long int js 
Javascript :: js add text after div 
Javascript :: storage class 
Javascript :: Array sum by function in javascript 
Javascript :: paper material ui 
Javascript :: javascript null or empty 
Javascript :: nodejs routes 
ADD CONTENT
Topic
Content
Source link
Name
5+3 =