-1
이것은 바보입니다. 그러나이 두 문장이 어떻게 다른 결과를 산출하는지 이해하는 데 어려움을 겪고 있습니다.JavaScript는 삼항 연산자를 줄입니다
'theyyyyy wheels on q bus'.split(' ').reduce((shortest, w) => {
return w.length < shortest.length ? shortest = w : shortest;
}) // 'q'
'theyyyyy wheels on q bus'.split(' ').reduce((shortest, w) => {
return shortest.length > w.lenght ? shortest = w : shortest;
}) // 'theyyyyy'
당신은 오타가 있습니다 :'lenght'는'length'이어야합니다 – RaphaMex
또한'shortest = w'를 지정해도 아무 것도 안됩니다. 그냥'w'를 반환하면 장면의 배후에서 'reduce'가 처리됩니다. –
당신이 그 일을 할 수 있는지 몰랐습니다. 고마워요. – user9009118