freeCodeCamp/curriculum/challenges/japanese/02-javascript-algorithms-an.../basic-javascript/concatenating-strings-with-...

2.0 KiB

id title challengeType videoUrl forumTopicId dashedName
56533eb9ac21ba0edf2244b7 文字列をプラス演算子で連結する 1 https://scrimba.com/c/cNpM8AN 16802 concatenating-strings-with-plus-operator

--description--

JavaScript では、+ 演算子を String の値に対して使用する場合、その演算子のことを連結演算子と呼びます。 他の文字列を一緒に連結することで新しい文字列を作ることができます。

'My name is Alan,' + ' I concatenate.'

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

例:

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

コンソールに、文字列 I come first. I come second. が表示されます。

--instructions--

+ 演算子を使用して、文字列 This is the start.This is the end. から myStr を作成してください。 2 つの文字列の間に空白を必ず含めるようにしてください。

--hints--

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

assert(myStr === 'This is the start. This is the end.');

+ 演算子を使用して myStr を作成する必要があります。

assert(code.match(/(["']).*\1\s*\+\s*(["']).*\2/g));

const キーワードを使用して myStr を作成する必要があります。

assert(/const\s+myStr/.test(code));

結果を myStr 変数に代入する必要があります。

assert(/myStr\s*=/.test(code));

--seed--

--after-user-code--

(function(){
  if(typeof myStr === 'string') {
    return 'myStr = "' + myStr + '"';
  } else {
    return 'myStr is not a string';
  }
})();

--seed-contents--

const myStr = ""; // Change this line

--solutions--

const myStr = "This is the start. " + "This is the end.";