Truncate a Script Wrong Hints

The challenge Truncate a Script from Basic Algorithm Scripting in the Javascript Algorithms and Data Structures Certification contains wrong solutions on the Hint Page.

I’m not sure if this is intentional or not, but just wanted to point that out. The solution doesn’t have to take into account the 3 dots other than returning them after truncating the string, as specified in the problem. The two solutions try to remove 3 characters just for the dots, and that’s unnecessary. The challenge doesn’t complete using the two solutions. Simply truncating the string if it’s longer than num and adding the dots does the trick - and works.

Here is a working solution(you can test that it passes, as well as that the 2 solutions on the Hint page don’t):

function truncateString(str, num) {

// Clear out that junk in your trunk

if (str.length > num) {

return str.slice(0, num) + '...';


else {

return str;



Don’t know who is in charge of maintaining that wiki, but hope this helps.

This issue has been corrected on the master branch, but the master branch has not been deployed since mid October. Once it has been deployed you will no longer see this incorrect solution. The reason it shows this solution is because is for an older version of the challenge which was more complicated.