* 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.7 KiB
1.7 KiB
id, title, challengeType, videoUrl, forumTopicId, dashedName
id | title | challengeType | videoUrl | forumTopicId | dashedName |
---|---|---|---|---|---|
56533eb9ac21ba0edf2244b8 | Concatenating Strings with the Plus Equals Operator | 1 | https://scrimba.com/c/cbQmmC4 | 16803 | concatenating-strings-with-the-plus-equals-operator |
--description--
We can also use the +=
operator to concatenate a string onto the end of an existing string variable. This can be very helpful to break a long string over several lines.
Note
Watch out for spaces. Concatenation does not add spaces between concatenated strings, so you'll need to add them yourself.
Example:
var ourStr = "I come first. ";
ourStr += "I come second.";
// ourStr is now "I come first. I come second."
--instructions--
Build myStr
over several lines by concatenating these two strings: "This is the first sentence. "
and "This is the second sentence."
using the +=
operator. Use the +=
operator similar to how it is shown in the editor. Start by assigning the first string to myStr
, then add on the second string.
--hints--
myStr
should have a value of This is the first sentence. This is the second sentence.
assert(myStr === 'This is the first sentence. This is the second sentence.');
You should use the +=
operator to build myStr
.
assert(code.match(/myStr\s*\+=\s*(["']).*\1/g));
--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.";