2.1 KiB
Raw Blame History

id, title, challengeType, videoUrl, localeTitle
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>var</code>关键字创建<code>myStr</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