* 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
1.6 KiB
1.6 KiB
id, title, challengeType, videoUrl, localeTitle
id | title | challengeType | videoUrl | localeTitle |
---|---|---|---|---|
bd7123c9c452eddfaeb5bdef | Use Bracket Notation to Find the Nth-to-Last Character in a String | 1 | 使用括号表示法查找字符串中的第N个到最后一个字符 |
Description
firstName[firstName.length - 3]
获取var firstName = "Charles"
字符串的倒数第三个字母的值Instructions
lastName
字符串中倒数第二个字符。 暗示 如果卡住,请尝试查看
thirdToLastLetterOfFirstName
变量声明。 Tests
tests:
- text: <code>secondToLastLetterOfLastName</code>应为“c”。
testString: assert(secondToLastLetterOfLastName === 'c');
- text: 你必须使用<code>.length</code>来获得倒数第二个字母。
testString: assert(code.match(/\.length/g).length === 2);
Challenge Seed
// Example
var firstName = "Ada";
var thirdToLastLetterOfFirstName = firstName[firstName.length - 3];
// Setup
var lastName = "Lovelace";
// Only change code below this line
var secondToLastLetterOfLastName = lastName;
After Test
console.info('after the test');
Solution
// solution required