0
let friends = ['Alfonso Waters', 'Mona', 'Mania','Mona Dunn', 'Mae','Mae Lane']
1

1 Answer 1

-1

Hope it's not too confusing :)

friends = ['Alfonso Waters', 'Mona', 'Mania','Mona Dunn', 'Mae','Mae Lane']
friends_lenght = friends.map(word => word.length)
friends_lenght_min_index = Math.min(...friends_lenght)
friend_index = friends_lenght.indexOf(friends_lenght_min_index)
friend = friends[friend_index]

// Output
// 'Mae'

p.s. You can make a function out of this code.

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

2 Comments

Glad to hear :) Click that this answer is correct so that the system understands that there is a solution. And if you can, please state that the answer was useful.
Thanks, the code writing was very well written so I understood it too easily

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.