14 lines
433 B
Markdown
14 lines
433 B
Markdown
|
---
|
||
|
title: Constructing Strings with Variables
|
||
|
localeTitle: 用变量构造字符串
|
||
|
---
|
||
|
## 用变量构造字符串
|
||
|
|
||
|
添加存储字符串的变量,以创建更长的字符串。确保你的拼写和间距是正确的。
|
||
|
```
|
||
|
var myName = "Bobby";
|
||
|
var myFavLetter = "B";
|
||
|
var sentence = "Hello, I'm " + myName + ". My favorite letter is " + myFavLetter + ".";
|
||
|
//The result is "Hello, I'm Bobby. My favorite letter is B.
|
||
|
|
||
|
```
|