3.4 KiB
3.4 KiB
id, title, challengeType, videoUrl, localeTitle
id | title | challengeType | videoUrl | localeTitle |
---|---|---|---|---|
56533eb9ac21ba0edf2244b6 | Escape Sequences in Strings | 1 | 字符串中的转义序列 |
Description
码 | 产量 |
---|---|
\' | 单引号 |
\" | 双引号 |
\\ | 反斜线 |
\n | 新队 |
\r | 回车 |
\t | 标签 |
\b | 退格 |
\f | 形式饲料 |
Instructions
myStr
。 第一行您将需要使用转义序列正确插入特殊字符。您还需要按照上面的间距来跟踪,在转义序列或单词之间没有空格。这是写出转义序列的文本。
\第二行
ThirdLine
FirstLinenewline
tab
backslash
SecondLinenewline
ThirdLine
Tests
tests:
- text: <code>myStr</code>不应包含任何空格
testString: 'assert(!/ /.test(myStr), "<code>myStr</code> should not contain any spaces");'
- text: <code>myStr</code>应包含的字符串<code>FirstLine</code> , <code>SecondLine</code>和<code>ThirdLine</code> (记住区分大小写)
testString: 'assert(/FirstLine/.test(myStr) && /SecondLine/.test(myStr) && /ThirdLine/.test(myStr), "<code>myStr</code> should contain the strings <code>FirstLine</code>, <code>SecondLine</code> and <code>ThirdLine</code> (remember case sensitivity)");'
- text: <code>FirstLine</code>后面应跟换行符<code>\n</code>
testString: 'assert(/FirstLine\n/.test(myStr), "<code>FirstLine</code> should be followed by the newline character <code>\n</code>");'
- text: <code>myStr</code>应该包含一个制表字符<code>\t</code> ,它跟在换行符后面
testString: 'assert(/\n\t/.test(myStr), "<code>myStr</code> should contain a tab character <code>\t</code> which follows a newline character");'
- text: <code>SecondLine</code>应该以反斜杠字符<code>\\</code>开头
testString: 'assert(/\SecondLine/.test(myStr), "<code>SecondLine</code> should be preceded by the backslash character <code>\\</code>");'
- text: <code>SecondLine</code>和<code>ThirdLine</code>之间应该有换行符
testString: 'assert(/SecondLine\nThirdLine/.test(myStr), "There should be a newline character between <code>SecondLine</code> and <code>ThirdLine</code>");'
Challenge Seed
var myStr; // Change this line
After Test
console.info('after the test');
Solution
// solution required