This file contains hidden or 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
// set up arrays | |
var numbers = [1,12,4,18,9,7,11,3,101,5,6]; | |
var strings = ['this','is','a','collection','of','words']; | |
// array.reduce - find largest number | |
var largestValue = numbers.reduce(function(x,y){ return x > y ? x : y }); | |
console.log('largest number: ' + largestValue); | |
// array.reduce - find longest string |
This file contains hidden or 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
// set up arrays | |
var numbers = [1,12,4,18,9,7,11,3,101,5,6]; | |
var strings = ['this','is','a','collection','of','words']; | |
// array.reduce - find largest number | |
var largestValue = numbers.reduce(function(x,y){ return x > y ? x : y }); | |
console.log('largest number: ' + largestValue); | |
// array.reduce - find longest string |