* 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>
1.5 KiB
1.5 KiB
id, title, challengeType, videoUrl, forumTopicId, dashedName
id | title | challengeType | videoUrl | forumTopicId | dashedName |
---|---|---|---|---|---|
56533eb9ac21ba0edf2244b8 | 用 += 运算符连接字符串 | 1 | https://scrimba.com/c/cbQmmC4 | 16803 | concatenating-strings-with-the-plus-equals-operator |
--description--
我们还可以使用+=
运算符来concatenate(拼接)字符串到现有字符串的结尾。对于那些被分割成几段的长的字符串来说,这一操作是非常有用的。
提示
注意空格。拼接操作不会在两个字符串之间添加空格,所以如果想要加上空格的话,你需要自己在字符串里面添加。
--instructions--
通过使用+=
操作符来连接这两个字符串:
"This is the first sentence. "
和"This is the second sentence."
并赋给变量myStr
。
--hints--
myStr
的值应该是This is the first sentence. This is the second sentence.
。
assert(myStr === 'This is the first sentence. This is the second sentence.');
使用+=
操作符创建myStr
变量。
assert(
code.match(/\w\s*\+=\s*["']/g).length > 1 &&
code.match(/\w\s*\=\s*["']/g).length > 1
);
--seed--
--after-user-code--
(function(){
if(typeof myStr === 'string') {
return 'myStr = "' + myStr + '"';
} else {
return 'myStr is not a string';
}
})();
--seed-contents--
// Only change code below this line
var myStr;
--solutions--
var myStr = "This is the first sentence. ";
myStr += "This is the second sentence.";