Files
freeCodeCamp/curriculum/challenges/ukrainian/02-javascript-algorithms-and-data-structures/basic-javascript/find-the-length-of-a-string.md
2023-01-30 18:58:54 +02:00

1.9 KiB
Raw Blame History

id, title, challengeType, videoUrl, forumTopicId, dashedName
id title challengeType videoUrl forumTopicId dashedName
bd7123c9c448eddfaeb5bdef Пошук довжини рядка 1 https://scrimba.com/c/cvmqEAd 18182 find-the-length-of-a-string

--description--

Ви можете знайти довжину значення String, написавши .length після рядкової змінної або рядкового літерала.

console.log("Alan Peter".length);

Консоль показуватиме значення 10. Зауважте, що пробіл між «Alan» та «Peter» також враховується.

Наприклад, якби ми створили змінну const firstName = "Ada", ми б змогли визначити довжину рядка Ada за допомогою властивості firstName.length.

--instructions--

Використайте властивість .length, щоб встановити lastNameLength на кількість символів у lastName.

--hints--

Ви не повинні змінювати оголошення змінних у розділі // Setup.

assert(
  code.match(/let lastNameLength = 0;/) &&
    code.match(/const lastName = "Lovelace";/)
);

lastNameLength має дорівнювати 8.

assert(typeof lastNameLength !== 'undefined' && lastNameLength === 8);

Ви повинні отримати довжину lastName, використовуючи .length, ось так: 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;