Instruções

Passo 11

O método slice() pode usar índices negativos para contar a partir do final da string. -1 se refere ao último caractere. Aqui está um exemplo:
const text = "JavaScript";
const lastThree = text.slice(-3);
console.log(lastThree); // "ipt"
Crie uma variável chamada endPunctuation. Depois, atribua a ela o resultado de usar message.slice(-1) para extrair o último caractere. Então use um template literal ou concatenação de strings para registrar a mensagem The ending punctuation mark is a "<endPunctuation>" no console. Substitua <endPunctuation> pelo valor real da variável.

O que fazer:

Testes:

  • Você deve declarar uma variável chamada `endPunctuation`.
  • Sua variável `endPunctuation` deve ser uma string.
  • Você deve usar `message.slice(-1)`.
  • Você deve atribuir o resultado de `message.slice(-1)` à sua variável `endPunctuation`.
  • Sua variável `endPunctuation` deve ser igual a `"!"`.
  • Você deve registrar a mensagem `The ending punctuation mark is a "<endPunctuation>"`, onde `<endPunctuation>` deve ser substituído pelo valor real da variável.

Console