freeCodeCamp/curriculum/challenges/portuguese/02-javascript-algorithms-an.../basic-javascript/use-bracket-notation-to-fin...

1.8 KiB

id title challengeType videoUrl localeTitle
bd7123c9c450eddfaeb5bdef Use Bracket Notation to Find the Nth Character in a String 1 Use a notação de suporte para localizar o caractere Nth em uma seqüência de caracteres

Description

Você também pode usar a notação de colchetes para obter o caractere em outras posições dentro de uma string. Lembre-se de que os computadores começam a contar a 0 , portanto, o primeiro caractere é, na verdade, o caractere zeroth.

Instructions

Vamos tentar definir thirdLetterOfLastName para igualar a terceira letra da variável lastName usando a notação de colchetes. Sugestão
Tente observar a declaração da variável secondLetterOfFirstName se você ficar preso.

Tests

tests:
  - text: A variável <code>thirdLetterOfLastName</code> deve ter o valor de <code>v</code> .
    testString: 'assert(thirdLetterOfLastName === "v", "The <code>thirdLetterOfLastName</code> variable should have the value of <code>v</code>.");'
  - text: Você deve usar a notação de colchetes.
    testString: 'assert(code.match(/thirdLetterOfLastName\s*?=\s*?lastName\[.*?\]/), "You should use bracket notation.");'

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