N개의 문자열이 입력되면 그 중 가장 긴 문자열을 출력하는 프로그램을 작성하세요.
▣ 입력설명
첫 줄에 자연수 N이 주어진다.(3<=N<=30)
두 번째 줄부터 N개의 문자열이 주어진다. 문자열의 길이는 100을 넘지 않습니다. 각 문자열의 길이는 서로 다릅니다.
▣ 출력설명
첫 줄에 가장 긴 문자열을 출력한다.
▣ 입력예제 1
5
teacher
time
student
beautiful
good
▣ 출력예제 1
beautiful
const input = `5
teacher
time
student
beautiful
good`.split("\n");
function solution(input) {
let answer;
for (let x = 1; x < input[0]; x++) {
if (input[x].length > input[x + 1].length) {
answer = input[x];
}
}
return answer;
}