Created
July 29, 2024 08:55
-
-
Save EntaltsevSN/9317a87ffb1285a67a841e8a334ae4f6 to your computer and use it in GitHub Desktop.
Удаление повторяемых слов из предложенного списка
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Объявляем переменную со списком слов | |
| const words = 'волны,мама,дорога,стол,мяч,книга,автомобиль,вода,школа,море,листья,солнце,ручка,огонь,дерево,солнце,цветок,школа,лес,книга'; | |
| // Объявляем переменную для очищенного списка | |
| let cleanWords; | |
| // Проверяем список на повторения и убираем лишнее | |
| const removeDuplicates = () => | |
| cleanWords = words.split(',').reduce((list, current) => | |
| list.includes(current) ? list : [...list, current], [] | |
| ).join(','); | |
| // Вызываем очистку от повторений | |
| removeDuplicates(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment