JSFiddle - React, Tailwind, and code Playground

by Cody Lindley

HTML

<script src="https://dl.dropboxusercontent.com/u/2026291/firebug-lite-debug.js"></script>

JavaScript

var add = function(previousValue, currentValue, index, array){ //show all arguments passed
    return previousValue + currentValue;
};

array1 = [2,4,6,3,6];

// add up all of the values in the array (from right to left)
// this of it like so (((6+3)+6)+4)+2
console.log(array1.reduceRight(add)); //log 21