--- id: 56533eb9ac21ba0edf2244b9 title: Constructing Strings with Variables challengeType: 1 videoUrl: '' localeTitle: 用变量构造字符串 --- ## Description
有时您需要构建一个字符串, Mad Libs样式。通过使用连接运算符( + ),您可以将一个或多个变量插入到正在构建的字符串中。
## Instructions
myName设置为等于您的名字的字符串,并在字符串"My name is "" and I am well!"之间用myName构建myStr " and I am well!"
## Tests
```yml tests: - text: myName应设置为至少3个字符长的字符串 testString: 'assert(typeof myName !== "undefined" && myName.length > 2, "myName should be set to a string at least 3 characters long");' - text: 使用两个+运算符在其中构建myStr with myName testString: 'assert(code.match(/[""]\s*\+\s*myName\s*\+\s*[""]/g).length > 0, "Use two + operators to build myStr with myName inside it");' ```
## Challenge Seed
```js // Example var ourName = "freeCodeCamp"; var ourStr = "Hello, our name is " + ourName + ", how are you?"; // Only change code below this line var myName; var myStr; ```
### After Test
```js console.info('after the test'); ```
## Solution
```js // solution required ```