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

2.7 KiB
Raw Blame History

id title challengeType videoUrl localeTitle
56533eb9ac21ba0edf2244b7 Concatenating Strings with Plus Operator 1 Конкатенация строк с помощью оператора Plus

Description

В JavaScript, когда оператор + используется со значением String , он называется оператором конкатенации . Вы можете создать новую строку из других строк путем конкатенации их вместе. пример
«Меня зовут Алан, +, я конкатенирую».
Заметка
Следите за пробелами. Конкатенация не добавляет пробелов между конкатенированными строками, поэтому вам нужно будет добавить их самостоятельно.

Instructions

Создайте myStr из строк "This is the start. " и "This is the end." используя оператор + .

Tests

tests:
  - text: <code>myStr</code> должен иметь значение <code>This is the start. This is the end.</code>
    testString: 'assert(myStr === "This is the start. This is the end.", "<code>myStr</code> should have a value of <code>This is the start. This is the end.</code>");'
  - text: Используйте оператор <code>+</code> для создания <code>myStr</code>
    testString: 'assert(code.match(/([""]).*([""])\s*\+\s*([""]).*([""])/g).length > 1, "Use the <code>+</code> operator to build <code>myStr</code>");'
  - text: <code>myStr</code> должен быть создан с использованием ключевого слова <code>var</code> .
    testString: 'assert(/var\s+myStr/.test(code), "<code>myStr</code> should be created using the <code>var</code> keyword.");'
  - text: Обязательно присвойте результат переменной <code>myStr</code> .
    testString: 'assert(/myStr\s*=/.test(code), "Make sure to assign the result to the <code>myStr</code> variable.");'

Challenge Seed

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

// Only change code below this line

var myStr;

After Test

console.info('after the test');

Solution

// solution required