А как вы код написали, если не можете понять, как он работает? <br/> <br/> Вы открывали <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/slice" rel="nofollow">документацию функции</a> , читали, что она делает и какие аргументы принимает? <br/> Ну, давайте я вам её сюда скопирую: <br/> <blockquote><b>Parameters</b><br/>
<code>indexStart</code><br/>
The index of the first character to include in the returned substring.<br/>
<code>indexEnd</code> Optional<br/>
The index of the first character to exclude from the returned substring.<br/>
<b>Description</b><br/>
If <code>indexStart < 0</code>, the index is counted from the end of the string. More formally, in this case, the substring starts at <code>max(indexStart + str.length, 0)</code>.<br/>
If <code>indexEnd < 0</code>, the index is counted from the end of the string. More formally, in this case, the substring ends at <code>max(indexEnd + str.length, 0)</code>.<br/>
</blockquote> <br/> <br/> <blockquote>зачем нужен (-2, -1)</blockquote> Для выполнения вот этого условия задачи: "если слово заканчивается на мягкий знак, то получите предпоследнюю букву". Я искренне не понимаю, что тут можно добавить...