Skip to content

Instantly share code, notes, and snippets.

@dongjinahn
Created February 14, 2018 08:55
Show Gist options
  • Select an option

  • Save dongjinahn/5bc6cd47d5b44000bfcd8a4ae7826706 to your computer and use it in GitHub Desktop.

Select an option

Save dongjinahn/5bc6cd47d5b44000bfcd8a4ae7826706 to your computer and use it in GitHub Desktop.
tterwer
let sum = 0;
for (let i = 0; i < arr.length; ++i) {
const item = arr[i];
sum += item.value;
}
sum = 0
for item in arr:
  sum += item["value"]
let sum = 0;
arr.forEach(function(item) {
  sum += item.value;
});
const sum = arr.reduce(function(acc, item) {
  return acc + item.value;
}, 0);
const sum = arr.reduce((acc, item) => acc + item.value, 0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment