* 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.4 KiB
1.4 KiB
id, title, challengeType, videoUrl, forumTopicId, dashedName
id | title | challengeType | videoUrl | forumTopicId | dashedName |
---|---|---|---|---|---|
56533eb9ac21ba0edf2244b9 | 用变量构造字符串 | 1 | https://scrimba.com/c/cqk8rf4 | 16805 | constructing-strings-with-variables |
--description--
有时候你需要创建一个类似Mad Libs(填词游戏)风格的字符串。通过使用连接运算符+
,你可以插入一个或多个变量来组成一个字符串。
--instructions--
把你的名字赋值给变量myName
,然后把变量myName
插入到字符串"My name is "
和" and I am well!"
之间,并把连接后的结果赋值给变量myStr
。
--hints--
myName
至少要包含三个字符。
assert(typeof myName !== 'undefined' && myName.length > 2);
使用两个+
操作符创建包含myName
的myStr
变量。
assert(code.match(/["']\s*\+\s*myName\s*\+\s*["']/g).length > 0);
--seed--
--after-user-code--
(function(){
var output = [];
if(typeof myName === 'string') {
output.push('myName = "' + myName + '"');
} else {
output.push('myName is not a string');
}
if(typeof myStr === 'string') {
output.push('myStr = "' + myStr + '"');
} else {
output.push('myStr is not a string');
}
return output.join('\n');
})();
--seed-contents--
// Only change code below this line
var myName;
var myStr;
--solutions--
var myName = "Bob";
var myStr = "My name is " + myName + " and I am well!";