function getLongestString(strings) { } /* Do not modify code below this line */ const strings = ['long', 'longer', 'longest']; console.log(getLongestString(strings), '<-- should be "longest"');

Respuesta :

tonb

Answer:

function getLongestString(strings) {  

return strings.reduce( (acc, cur) => acc.length > cur.length ? acc : cur);

}

Explanation:

A reducer applies the same operation to each array element. In this case, the longest string is stored in the accumulator (acc), and is replaced only by the current element (cur) if the current element is longer than the accumulator.