Answers for "return longest string from array"

3

return longest string from array

arr.reduce((a, b)=> a.length > b.length ? a : b);
Posted by: Guest on March-25-2022
3

javascript return longest string in array

function data(str){
           var show = str.split(" ");
            show.sort(function (a,b){
                return b.length - a.length; 
            })
            return show[0];
      }
      console.log(data(str = "javascript is my favourite language "));
Posted by: Guest on October-18-2020
0

javascript find the longest string in array

Math.max(...(x.map(el => el.length)));
Posted by: Guest on October-02-2020

Code answers related to "return longest string from array"

Code answers related to "Javascript"

Browse Popular Code Answers by Language