Oliver Eyton-Williams ee1e8abd87
feat(curriculum): restore seed + solution to Chinese (#40683)
* feat(tools): add seed/solution restore script

* chore(curriculum): remove empty sections' markers

* chore(curriculum): add seed + solution to Chinese

* chore: remove old formatter

* fix: update getChallenges

parse translated challenges separately, without reference to the source

* chore(curriculum): add dashedName to English

* chore(curriculum): add dashedName to Chinese

* refactor: remove unused challenge property 'name'

* fix: relax dashedName requirement

* fix: stray tag

Remove stray `pre` tag from challenge file.

Signed-off-by: nhcarrigan <nhcarrigan@gmail.com>

Co-authored-by: nhcarrigan <nhcarrigan@gmail.com>
2021-01-12 19:31:00 -07:00

2.6 KiB

id, title, challengeType, videoUrl, forumTopicId, dashedName
id title challengeType videoUrl forumTopicId dashedName
56533eb9ac21ba0edf2244b6 字符串中的转义序列 1 https://scrimba.com/c/cvmqRh6 17567 escape-sequences-in-strings

--description--

引号不是字符串中唯一可以被转义的字符。使用转义字符有两个原因:首先是可以让你使用无法输入的字符,例如退格。其次是可以让你在一个字符串中表示多个引号,而不会出错。我们在之前的挑战中学到了这个。

代码输出
\'单引号
\"双引号
\\反斜杠
\n换行符
\r回车符
\t制表符
\b退格
\f换页符

请注意,必须对反斜杠本身进行转义才能显示为反斜杠。

--instructions--

使用转义字符将下面三行文本字符串赋给变量myStr

FirstLine
    \SecondLine
ThirdLine

你需要使用转义字符正确地插入特殊字符,确保间距与上面文本一致并且单词或转义字符之间没有空格。

像这样用转义字符写出来:

"FirstLine换行符``制表符``反斜杠SecondLine换行符ThirdLine"

--hints--

myStr不能包含空格。

assert(!/ /.test(myStr));

myStr应该包含字符串FirstLine, SecondLine and ThirdLine (记得区分大小写)。

assert(
  /FirstLine/.test(myStr) && /SecondLine/.test(myStr) && /ThirdLine/.test(myStr)
);

FirstLine后面应该是一个新行\n

assert(/FirstLine\n/.test(myStr));

myStr应该包含制表符\t并且制表符要在换行符后面。

assert(/\n\t/.test(myStr));

SecondLine前面应该是反斜杠\\

assert(/\SecondLine/.test(myStr));

SecondLineThirdLine之间应该是换行符。

assert(/SecondLine\nThirdLine/.test(myStr));

myStr 应该只包含介绍里面展示的字符串。

assert(myStr === 'FirstLine\n\t\\SecondLine\nThirdLine');

--seed--

--after-user-code--

(function(){
if (myStr !== undefined){
console.log('myStr:\n' + myStr);}})();

--seed-contents--

var myStr; // Change this line

--solutions--

var myStr = "FirstLine\n\t\\SecondLine\nThirdLine";