Answers for "array objects to array of one property"

0

array objects to array of one property

function getArraySum(arr) {
	let total = 0; i = arr.length;
    while(i--) total += arr[i];
    return total;
}
var numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
getArraySum(numbers);
Posted by: Guest on July-20-2021
0

Getting One Value from an Array of Items

//Getting One Value from an Array of Items or sum of array
var numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
var total = numbers.reduce(function(total, current) {
    return total + current;
}, 0);

console.log(total);
Posted by: Guest on July-10-2020

Code answers related to "array objects to array of one property"

Code answers related to "TypeScript"

Browse Popular Code Answers by Language