-1

Here is an example array:

var friendName = ['RupaKhan','Sunny','Rohul','Mistry','Zumman','Asif','Liza','Fulo'];

How do you find the longest name in the array? But you have to use a function with return as well as find as largest name.

I tried this method but it doesn't show a result:

enter image description here

2

1 Answer 1

0

var friendName = ['RupaKhan','Sunny','Rohul','Mistry','Zumman','Asif','Liza','Fulo'];

function mega(arr){
   return arr.reduce((max,name)=>{
        return name.length > max.length? name: max
    },arr[0])
}

console.log(mega(friendName))

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.