Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * returns the largest positive number in a given array
- * @param {Array} arr [the array to act on]
- * @return {Array} [the largest number]
- */
- function getLargestPosNumInArr(arr) {
- return arr.reduce(function(prevVal, curVal) {
- if (curVal > prevVal) {
- prevVal = curVal;
- }
- return prevVal;
- }, 0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement