mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2025-12-20 10:38:17 -05:00
1.7 KiB
1.7 KiB
id, title, challengeType, videoUrl, forumTopicId, dashedName
| id | title | challengeType | videoUrl | forumTopicId | dashedName |
|---|---|---|---|---|---|
| 56533eb9ac21ba0edf2244ed | Anhängen von Variablen an Strings | 1 | https://scrimba.com/c/cbQmZfa | 16656 | appending-variables-to-strings |
--description--
Genauso wie wir einen String über mehrere Zeilen aus Literalen aufbauen können, können wir auch Variablen an einen String anhängen, indem wir den Plus-Gleichheits-Operator (+=) verwenden.
Beispiel:
const anAdjective = "awesome!";
let ourStr = "freeCodeCamp is ";
ourStr += anAdjective;
ourStr hätte dann den Wert freeCodeCamp is awesome!.
--instructions--
Setze someAdjective auf einen String von mindestens 3 Zeichen und füge ihn mit dem Operator += an myStr an.
--hints--
someAdjective sollte auf einen String mit mindestens 3 Zeichen Länge gesetzt werden.
assert(typeof someAdjective !== 'undefined' && someAdjective.length > 2);
Du solltest someAdjective an myStr mit dem Operator += anhängen.
assert(code.match(/myStr\s*\+=\s*someAdjective\s*/).length > 0);
--seed--
--after-user-code--
(function(){
var output = [];
if(typeof someAdjective === 'string') {
output.push('someAdjective = "' + someAdjective + '"');
} else {
output.push('someAdjective 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--
// Change code below this line
const someAdjective = "";
let myStr = "Learning to code is ";
--solutions--
const someAdjective = "neat";
let myStr = "Learning to code is ";
myStr += someAdjective;