freeCodeCamp/curriculum/challenges/chinese/02-javascript-algorithms-and-data-structures/basic-javascript/use-bracket-notation-to-find-the-nth-character-in-a-string.chinese.md
Kristofer Koishigawa b3213fc892 fix(i18n): chinese test suite (#38220)
* fix: Chinese test suite

Add localeTiltes, descriptions, and adjust test text and testStrings to get the automated test suite working.

* fix: ran script, updated testStrings and solutions
2020-03-03 18:49:47 +05:30

1.5 KiB
Raw Blame History

id, title, challengeType, videoUrl, localeTitle
id title challengeType videoUrl localeTitle
bd7123c9c450eddfaeb5bdef Use Bracket Notation to Find the Nth Character in a String 1 使用括号表示法查找字符串中的第N个字符

Description

您还可以使用括号表示法来获取字符串中其他位置的字符。请记住,计算机从0开始计数因此第一个字符实际上是第0个字符。

Instructions

让我们尝试使用括号表示法将thirdLetterOfLastName设置为等于lastName变量的第三个字母。 暗示
如果卡住,请尝试查看secondLetterOfFirstName变量声明。

Tests

tests:
  - text: <code>thirdLetterOfLastName</code>变量的值应为<code>v</code> 。
    testString: assert(thirdLetterOfLastName === 'v');
  - text: 您应该使用括号表示法。
    testString: assert(code.match(/thirdLetterOfLastName\s*?=\s*?lastName\[.*?\]/));

Challenge Seed

// Example
var firstName = "Ada";
var secondLetterOfFirstName = firstName[1];

// Setup
var lastName = "Lovelace";

// Only change code below this line.
var thirdLetterOfLastName = lastName;

After Test

console.info('after the test');

Solution

// solution required