Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

js array find string element with max length

// find the max length of string elements in an array
arr = ['1', '12', '123'];
max = Math.max(...arr.map(element => element.length));
// returns 3, the length of the string '123'
 
PREVIOUS NEXT
Tagged: #js #array #find #string #element #max #length
ADD COMMENT
Topic
Name
1+8 =