Files
freeCodeCamp/curriculum/challenges/ukrainian/02-javascript-algorithms-and-data-structures/basic-javascript/concatenating-strings-with-plus-operator.md
freeCodeCamp's Camper Bot e6b05ee25d chore(i18n,learn): processed translations (#54537)
Co-authored-by: Naomi <nhcarrigan@gmail.com>
2024-04-26 12:26:37 +07:00

2.5 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(__helpers.removeJSComments(code).match(/(["']).*\1\s*\+\s*(["']).*\2/g));

Ви повинні використати ключове слово const, щоб створити myStr.

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

Ви повинні присвоїти результат до змінної myStr.

assert(/myStr\s*=/.test(__helpers.removeJSComments(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.";