문제
문제 링크 : Maximum Number of Words Found in Sentences
풀이
var mostWordsFound = function(sentences) {
return sentences.reduce( (maxNum, sentence) => {
return Math.max(maxNum, sentence.split(' ').length)
}, 0)
};
- 배열 sentences를 reduce문을 통해 maxNum을 계산
- Runtime 50 ms, Memory 44.53 MB