Здраствуйте, подскажите почему у меня пройшла проверка если первую фразу обрезало на половине слова?
functions.js
export const shortenByWords = (s, n) => {
if (n >= s.length) {
return s
}
return s.slice(0, n) + '...'
}
solution.js
import { shortenByWords } from './functions.js';
const longString = 'this string is quiteeeeeeeeeeeeeee long, especially for its age.'
const shortString = 'a short one'
console.log(shortenByWords(longString, 20));
console.log(shortenByWords(shortString, 20));