1.5 KiB
1.5 KiB
id, title, challengeType, videoUrl, forumTopicId, dashedName
| id | title | challengeType | videoUrl | forumTopicId | dashedName |
|---|---|---|---|---|---|
| bd7123c9c448eddfaeb5bdef | Encontrar o tamanho de uma string | 1 | https://scrimba.com/c/cvmqEAd | 18182 | find-the-length-of-a-string |
--description--
Você pode encontrar o tamanho de um valor de String ao escrever .length após a variável de string ou literal de string.
console.log("Alan Peter".length);
O valor 10 seria exibido no console.
Por exemplo, se nós criássemos uma variável const firstName = "Ada", poderíamos descobrir qual o tamanho da string Ada usando a propriedade firstName.length.
--instructions--
Use a propriedade .length para contar o número de caracteres na variável lastName e atribui-la a lastNameLength.
--hints--
Você não deve alterar as declarações de variáveis na seção // Setup.
assert(
code.match(/let lastNameLength = 0;/) &&
code.match(/const lastName = "Lovelace";/)
);
lastNameLength deve ser igual a oito.
assert(typeof lastNameLength !== 'undefined' && lastNameLength === 8);
Você deve estar recebendo o tamanho de lastName ao usar .length dessa forma: lastName.length.
assert(code.match(/=\s*lastName\.length/g) && !code.match(/lastName\s*=\s*8/));
--seed--
--seed-contents--
// Setup
let lastNameLength = 0;
const lastName = "Lovelace";
// Only change code below this line
lastNameLength = lastName;
--solutions--
let lastNameLength = 0;
const lastName = "Lovelace";
lastNameLength = lastName.length;