Hi,
I implemented Task-145 as specified below.
The output seems correct:
PS C:\Coding\cdsl> node c:/Coding/cdsl/task145/solution.js
this string is...
a short one
However, upon task-submit the verification engine fails me on the following items. Please advise why the test doesn't pass.
- The result should include only the full words
- The result should end with ... if the original string had to be shortened
export const shortenByWords = (s, n) => {
var newS = "";
if(s.length <= n) {
newS = s;
} else{
for(var i = n; i > 0; i--) {
if(s.charAt(i) == " " && s.charAt(i - 1) != " ") {
newS = `${s.substring(0, i)}...`;
break;
}
}
}
return newS;
}
'''
Thanks