24
2
Your challenge is to take an array of strings and output the longest string in the array. So for
["tiny", "small", "bigger", "biggest"]
the output would be biggest
.
If two elements of the array have the same length, you should choose the one that appears first in the array. That means if the array looks like this:
["one", "two", "no"]
the output is one
, but if the array looked like this:
["two", "one", "no"]
the output is two
.
As this is code-golf, the shortest code in bytes wins.
3
2 notes:
– user202729 – 2017-12-20T10:54:16.4201
It's heavily discouraged if the question is changed and invalidates existing answer, and2
the Sandbox exists for exactly that reason (make sure challenges are good before posting)4Since I don't think anyone else has mentioned it -- Hi, and welcome to PPCG! – AdmBorkBork – 2017-12-20T14:21:19.217
Do you have any other test cases? Should we handle the case where the array is empty and, if so, how? – Luke Stevens – 2017-12-20T14:22:42.640
1No you don't have to handle the case where the array is empty. But if you want you can. – Doggo – 2017-12-20T14:25:51.163
42 hours? That's far, far too quick to be accepting an answer. – Shaggy – 2017-12-20T15:05:21.947
@Shaggy I un accepted the answer i will look into it tomorrow. – Doggo – 2017-12-20T16:29:12.830
6Normally you wait a week – Christopher – 2017-12-20T16:43:00.123
-1 because this is a fairly trivial challenge. – Esolanging Fruit – 2017-12-22T18:28:10.750