mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-01-10 09:05:55 -05:00
2.2 KiB
2.2 KiB
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 повинен мати таке ж значення як і рядок 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));
Для створення myStr потрібно використати ключове слово const.
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.";