Files
freeCodeCamp/curriculum/challenges/ukrainian/02-javascript-algorithms-and-data-structures/basic-javascript/concatenating-strings-with-plus-operator.md
2022-12-19 20:41:09 +02:00

2.4 KiB
Raw Blame History

id, title, challengeType, videoUrl, forumTopicId, dashedName
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--

Побудуйте myStr з рядків This is the start. та This is the end., використовуючи оператор +. Не забудьте використати пробіл між двома рядками.

--hints--

myStr повинен містити один пробіл між двома рядками.

assert(/start\. This/.test(myStr));

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.";