Advertisement
thetenfold

Untitled

Sep 15th, 2013
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // define the array
  2. var myarray = ['a', 'abcde', 'ab'];
  3.  
  4. // convert each item in the array to a
  5. // number representing its length
  6. var myarray_lengths = myarray.map(function (item) { return item.length; });
  7.  
  8. // use Math.max() and .apply() to figure out the longest string
  9. var highest_length = Math.max.apply(Math, myarray_lengths);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement