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

1.9 KiB

id, title, challengeType, videoUrl, forumTopicId, dashedName
id title challengeType videoUrl forumTopicId dashedName
56533eb9ac21ba0edf2244b8 文字列を += 演算子で連結する 1 https://scrimba.com/c/cbQmmC4 16803 concatenating-strings-with-the-plus-equals-operator

--description--

+= 演算子を使用して、既存の文字列変数の末尾に文字列を連結することもできます。 これは長い文字列を複数行に分割する場合にとても便利です。

注: 空白が必要な場合は注意してください。 連結では、文字列の間に空白が追加されないため、必要な場合は自分で付け加える必要があります。

例:

let ourStr = "I come first. ";
ourStr += "I come second.";

これで ourStr の値は文字列 I come first. I come second. になります。

--instructions--

+= 演算子を使用して、This is the first sentence.This is the second sentence. の 2 つの文字列を連結し、複数行にわたる myStr を作成してください。 前の例のように、+= 演算子を使用し、必ず 2 つの文字列の間に空白を入れてください。 まず myStr に 1 つ目の文字列を代入し、それから 2 つ目の文字列を追加してください。

--hints--

myStr の値が文字列値 This is the first sentence. This is the second sentence. になる必要があります。

assert(myStr === 'This is the first sentence. This is the second sentence.');

+= 演算子を使用して 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--

let myStr;

--solutions--

let myStr = "This is the first sentence. ";
myStr += "This is the second sentence.";