Find the longest string in an array of strings in Javascript
//input an array of string and output a string
let arrStr = ["hi", "hello", "test", "this is great", "this is awesome"];
const longestString = (arrStr) => {
let longest = '';
arrStr.forEach((item) => {
if (item.length >longest.length) {
longest = item;
}
});
return longest;
}
console.log(longestString(arrStr));