Files
2022-01-20 20:30:18 +01:00

1.8 KiB

id, title, challengeType, videoUrl, forumTopicId, dashedName
id title challengeType videoUrl forumTopicId dashedName
56533eb9ac21ba0edf2244ed 文字列への変数の連結 1 https://scrimba.com/c/cbQmZfa 16656 appending-variables-to-strings

--description--

複数行の文字列リテラルから文字列を作成することができますが、それと同じように、加算代入 (+=) 演算子を使用して変数を文字列に連結することができます。

例:

const anAdjective = "awesome!";
let ourStr = "freeCodeCamp is ";
ourStr += anAdjective;

ourStr の値は freeCodeCamp is awesome! となります。

--instructions--

someAdjective に 3 文字以上の文字列を設定し、+= 演算子を使用して myStr に連結してください。

--hints--

someAdjective には 3 文字以上の長さの文字列を設定する必要があります。

assert(typeof someAdjective !== 'undefined' && someAdjective.length > 2);

+= 演算子を使用して、someAdjectivemyStr に連結する必要があります。

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;