From 1c54ab471a1678071580e274dcba984691a8c1b0 Mon Sep 17 00:00:00 2001 From: Eric Leung Date: Sat, 18 Jun 2016 23:16:11 -0700 Subject: [PATCH] Clarify Escape Sequences in Strings challenge - Add code tags into table - Rewrite instructions for more applicable coding test - Add more tests to be more specific on what you need to pass --- .../basic-javascript.json | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/seed/challenges/01-front-end-development-certification/basic-javascript.json b/seed/challenges/01-front-end-development-certification/basic-javascript.json index 4cce7dc64d..198a4e064c 100644 --- a/seed/challenges/01-front-end-development-certification/basic-javascript.json +++ b/seed/challenges/01-front-end-development-certification/basic-javascript.json @@ -1036,10 +1036,14 @@ "title": "Escape Sequences in Strings", "description": [ "Quotes are not the only characters that can be escaped inside a string. Here is a table of common escape sequences:", - "
CodeOutput
\\'single quote
\\\"double quote
\\\\backslash
\\nnew line
\\rcarriage return
\\ttab
\\bbackspace
\\fform feed
", + "
CodeOutput
\\'single quote
\\\"double quote
\\\\backslash
\\nnew line
\\rcarriage return
\\ttab
\\bbackspace
\\fform feed
", "Note that the backslash itself must be escaped in order to display as a backslash.", "

Instructions

", - "Encode the following sequence, separated by spaces:
backslash tab tab carriage-return new-line and assign it to myStr" + "Assign the following two lines of text into the single variable myStr using escape sequences.", + "
Here is a backslash: \\.
        Here is a new line with two tabs.
", + "You will need to use escape sequences to insert special characters correctly. You will also need to follow the spacing as it looks above with no additional spaces between each escape sequence.", + "Here is the text with the escape sequences written out.", + "Here is a backslash: backslash.newline tab tab Here is a new line with two tabs." ], "releasedOn": "January 1, 2016", "challengeSeed": [ @@ -1054,10 +1058,14 @@ "else{return null;}})();" ], "solutions": [ - "var myStr = \"\\\\ \\t \\t \\r \\n\";" + "var myStr = \"Here is a backslash: \\\\.\\n\\t\\tHere is a new line with two tabs.\";" ], "tests": [ - "assert(myStr === \"\\\\ \\t \\t \\r \\n\", 'message: myStr should have the escape sequences for backslash tab tab carriage-return new-line separated by spaces');" + "assert(myStr === \"Here is a backslash: \\\\.\\n\\t\\tHere is a new line with two tabs.\", 'message: myStr should have encoded text with the proper escape sequences and spacing.');", + "assert(myStr.match(/\\t/g).length == 2, 'message: myStr should have two tab characters \\t');", + "assert(myStr.match(/\\n/g).length == 1, 'message: myStr should have one newline character \\n');", + "assert(myStr.match(/\\\\/g).length == 1, 'message: myStr should have a correctly escaped backslash character \\\\');", + "assert(myStr === \"Here is a backslash: \\\\.\\n\\t\\tHere is a new line with two tabs.\", 'message: myStr should not have any spaces in between consecutive escape sequences.');" ], "type": "waypoint", "challengeType": 1,