--- id: 56533eb9ac21ba0edf2244b8 title: Concatenating Strings with the Plus Equals Operator challengeType: 1 videoUrl: '' localeTitle: 使用Plus Equals运算符连接字符串 --- ## Description
我们还可以使用+=运算符将字符串连接到现有字符串变量的末尾。这对于在多行上打破长字符串非常有帮助。 注意
留意空间。连接不会在连接字符串之间添加空格,因此您需要自己添加它们。
## Instructions
通过连接这两个字符串来构建myStr几行: "This is the first sentence. ""This is the second sentence."使用+=运算符。使用+=运算符,类似于它在编辑器中的显示方式。首先将第一个字符串分配给myStr ,然后添加第二个字符串。
## Tests
```yml tests: - text: myStr应该有一个值This is the first sentence. This is the second sentence. testString: assert(myStr === "This is the first sentence. This is the second sentence."); - text: 使用+=运算符构建myStr testString: assert(code.match(/\w\s*\+=\s*["']/g).length > 1 && code.match(/\w\s*\=\s*["']/g).length > 1); ```
## Challenge Seed
```js // Example var ourStr = "I come first. "; ourStr += "I come second."; // Only change code below this line var myStr; ```
### After Test
```js console.info('after the test'); ```
## Solution
```js // solution required ```