반응형
See the Pen reduceRight() by nilgi (@nilgi) on CodePen.
<h3>reduceRight() : 요소에 함수를 건다. 오른쪽부터</h3>
<p id="rR1"></p>
<script type="text/javascript">
const num1 = [165, 69, 23, 4, 777, 236];
let plus1 = num1.reduceRight(myFunction);
document.getElementById("rR1").innerHTML = plus1;
function myFunction(total, value, index, array) {
return total + value;
}
</script>
반응형