1.9 KiB
1.9 KiB
id | title | challengeType | videoUrl | localeTitle |
---|---|---|---|---|
bd7123c9c452eddfaeb5bdef | Use Bracket Notation to Find the Nth-to-Last Character in a String | 1 | Use a notação de suporte para localizar o caractere N-para-último em uma seqüência de caracteres |
Description
var firstName = "Charles"
usando firstName[firstName.length - 3]
Instructions
lastName
. Sugestão Tente observar a declaração da variável
thirdToLastLetterOfFirstName
se você ficar preso. Tests
tests:
- text: <code>secondToLastLetterOfLastName</code> deve ser "c".
testString: 'assert(secondToLastLetterOfLastName === "c", "<code>secondToLastLetterOfLastName</code> should be "c".");'
- text: Você tem que usar o <code>.length</code> para obter a segunda última letra.
testString: 'assert(code.match(/\.length/g).length === 2, "You have to use <code>.length</code> to get the second last letter.");'
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