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

1.8 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 的に文字列を作成しなければならない場合があります。 連結演算子 (+) を使用して、作成する文字列に 1 つまたは複数の変数を挿入することができます。

例:

const ourName = "freeCodeCamp";
const ourStr = "Hello, our name is " + ourName + ", how are you?";

ourStr の値は文字列 Hello, our name is freeCodeCamp, how are you? となります。

--instructions--

myName にあなたの名前と同じ文字列を設定し、文字列 My name isand I am well! の間に myName を挿入した myStr を作成してください。

--hints--

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

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

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
const myName = "";
const myStr = "";

--solutions--

const myName = "Bob";
const myStr = "My name is " + myName + " and I am well!";