Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // define the array
- var myarray = ['a', 'abcde', 'ab'];
- // convert each item in the array to a
- // number representing its length
- var myarray_lengths = myarray.map(function (item) { return item.length; });
- // use Math.max() and .apply() to figure out the longest string
- var highest_length = Math.max.apply(Math, myarray_lengths);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement