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.";
The string I come first. I come second. would be displayed in the console.
--instructions--
Створіть myStr з рядків This is the start. й This is the end. за допомогою + оператору. Обов'язково використовуйте пробіл між двома рядками.
--hints--
myStr should have a single space character between the two strings.
assert(/start\. This/.test(myStr));
myStr should have a value of the string This is the start. This is the end.
assert(myStr === 'This is the start. This is the end.');
You should use the + operator to build myStr.
assert(code.match(/(["']).*\1\s*\+\s*(["']).*\2/g));
myStr should be created using the const keyword.
assert(/const\s+myStr/.test(code));
You should assign the result to the myStr variable.
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.";