Created
July 21, 2020 00:48
-
-
Save PUYUP/bd5e307eca75eca672449d65ad7df509 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript"> | |
var arr_init = [1,2,3,'=',80,10]; | |
var sum_init = arr_init.reduce((total, current, index, arr) => { | |
var i = arr.indexOf('='); | |
var arr_slice = arr.slice(0, i); | |
var sum = arr_slice.reduce((t, c) => t + c, 0); | |
return sum; | |
}, 0); | |
console.log(sum_init); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment