The Longest Word

Problem

Write a program that prints the longest of N strings when inputted.

input

A natural number N is given in the first line (3<=N<=30). Starting from the second line, N strings are given. The length of the string does not exceed 100. Each string has a different length.

5
teacher
time
student
beautiful
good

output

Print the longest string on the first line.

beautiful

Solution

function solution(s) {
	let answer = '',
		max = Number.MIN_SAFE_INTEGER;
	for (let x of s) {
		if (max < x.length) {
			max = x.length;
			answer = x;
		}
	}
	return answer;
}