The task is to ask the user text of arbitrary length; find the three longest words in the entered text. So I requested the text, broke the words in the array, removed the extra commas, even created a new array with word lengths. In essence, the task is to find the 3 largest from an array of numbers.
var text = prompt('Введите любой произвольный текст', 'Футбол это игра, целью которой является забить мяч в ворота противника'); var textArr = text.split(' '); for (i = 0; i < textArr.length; i++) { textArr[i] = textArr[i].replace(',', ''); }; var textArrLength = []; for (i = 0; i < textArr.length; i++) { textArrLength[i] = textArr[i].length; };