From 3236b6265140a79809b599c08e47601b0e65c602 Mon Sep 17 00:00:00 2001 From: Aniruddh Agarwal Date: Thu, 15 Oct 2015 16:58:19 +0800 Subject: [PATCH] Add test to truncate string --- challenges/basic-bonfires.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/challenges/basic-bonfires.json b/challenges/basic-bonfires.json index c7ec06d6a2..d3a0f22893 100644 --- a/challenges/basic-bonfires.json +++ b/challenges/basic-bonfires.json @@ -369,6 +369,7 @@ "description": [ "Truncate a string (first argument) if it is longer than the given maximum string length (second argument). Return the truncated string with a \"...\" ending.", "Note that the three dots at the end add to the string length.", + "If the length of the string is less than or equal to 3 characters, then the length of the three dots is not added to the string length.", "Remember to use Read-Search-Ask if you get stuck. Write your own code." ], "challengeSeed": [ @@ -383,7 +384,8 @@ "assert(truncate(\"A-tisket a-tasket A green and yellow basket\", 11) === \"A-tisket...\", 'message: truncate(\"A-tisket a-tasket A green and yellow basket\", 11) should return \"A-tisket...\".');", "assert(truncate(\"Peter Piper picked a peck of pickled peppers\", 14) === \"Peter Piper...\", 'message: truncate(\"Peter Piper picked a peck of pickled peppers\", 14) should return \"Peter Piper...\".');", "assert(truncate(\"A-tisket a-tasket A green and yellow basket\", \"A-tisket a-tasket A green and yellow basket\".length) === \"A-tisket a-tasket A green and yellow basket\", 'message: truncate(\"A-tisket a-tasket A green and yellow basket\", \"A-tisket a-tasket A green and yellow basket\".length) should return \"A-tisket a-tasket A green and yellow basket\".');", - "assert(truncate('A-tisket a-tasket A green and yellow basket', 'A-tisket a-tasket A green and yellow basket'.length + 2) === 'A-tisket a-tasket A green and yellow basket', 'message: truncate(\"A-tisket a-tasket A green and yellow basket\", \"A-tisket a-tasket A green and yellow basket\".length + 2) should return \"A-tisket a-tasket A green and yellow basket\".');" + "assert(truncate('A-tisket a-tasket A green and yellow basket', 'A-tisket a-tasket A green and yellow basket'.length + 2) === 'A-tisket a-tasket A green and yellow basket', 'message: truncate(\"A-tisket a-tasket A green and yellow basket\", \"A-tisket a-tasket A green and yellow basket\".length + 2) should return \"A-tisket a-tasket A green and yellow basket\".');", + "assert(truncate(\"A-\", 1) === \"A...\", 'message: truncate(\"A-\", 1) should return \"A...\".');" ], "MDNlinks": [ "String.slice()"