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

2.6 KiB
Raw Blame History

id title challengeType videoUrl localeTitle
56533eb9ac21ba0edf2244b8 Concatenating Strings with the Plus Equals Operator 1 Объединение строк с помощью оператора Plus Equals

Description

Мы также можем использовать оператор += для конкатенации строки в конец существующей строковой переменной. Это может быть очень полезно для разбиения длинной строки на несколько строк. Заметка
Следите за пробелами. Конкатенация не добавляет пробелов между конкатенированными строками, поэтому вам нужно будет добавить их самостоятельно.

Instructions

Постройте myStr в нескольких строках, myStr эти две строки: "This is the first sentence. " и "This is the second sentence." используя оператор += . Используйте оператор += аналогичный тому, как он отображается в редакторе. Начните с назначения первой строки myStr , затем добавьте вторую строку.

Tests

tests:
  - text: <code>myStr</code> должно иметь значение <code>This is the first sentence. This is the second sentence.</code>
    testString: 'assert(myStr === "This is the first sentence. This is the second sentence.", "<code>myStr</code> should have a value of <code>This is the first sentence. This is the second sentence.</code>");'
  - text: Используйте оператор <code>+=</code> для создания <code>myStr</code>
    testString: 'assert(code.match(/\w\s*\+=\s*[""]/g).length > 1 && code.match(/\w\s*\=\s*[""]/g).length > 1, "Use the <code>+=</code> operator to build <code>myStr</code>");'

Challenge Seed

// Example
var ourStr = "I come first. ";
ourStr += "I come second.";

// Only change code below this line

var myStr;

After Test

console.info('after the test');

Solution

// solution required