--- id: bd7123c9c450eddfaeb5bdef title: Use Bracket Notation to Find the Nth Character in a String challengeType: 1 videoUrl: '' localeTitle: 使用括号表示法查找字符串中的第N个字符 --- ## Description
您还可以使用括号表示法来获取字符串中其他位置的字符。请记住,计算机从0开始计数,因此第一个字符实际上是第0个字符。
## Instructions
让我们尝试使用括号表示法将thirdLetterOfLastName设置为等于lastName变量的第三个字母。 暗示
如果卡住,请尝试查看secondLetterOfFirstName变量声明。
## Tests
```yml tests: - text: thirdLetterOfLastName变量的值应为v 。 testString: 'assert(thirdLetterOfLastName === "v", "The thirdLetterOfLastName variable should have the value of v.");' - text: 您应该使用括号表示法。 testString: 'assert(code.match(/thirdLetterOfLastName\s*?=\s*?lastName\[.*?\]/), "You should use bracket notation.");' ```
## Challenge Seed
```js // Example var firstName = "Ada"; var secondLetterOfFirstName = firstName[1]; // Setup var lastName = "Lovelace"; // Only change code below this line. var thirdLetterOfLastName = lastName; ```
### After Test
```js console.info('after the test'); ```
## Solution
```js // solution required ```