Files
freeCodeCamp/curriculum/challenges/ukrainian/02-javascript-algorithms-and-data-structures/basic-javascript/use-bracket-notation-to-find-the-last-character-in-a-string.md
freeCodeCamp's Camper Bot e6b05ee25d chore(i18n,learn): processed translations (#54537)
Co-authored-by: Naomi <nhcarrigan@gmail.com>
2024-04-26 12:26:37 +07:00

1.7 KiB
Raw Blame History

id, title, challengeType, videoUrl, forumTopicId, dashedName
id title challengeType videoUrl forumTopicId dashedName
bd7123c9c451eddfaeb5bdef Дужкова нотація для пошуку останнього символа рядка 1 https://scrimba.com/c/cBZQGcv 18342 use-bracket-notation-to-find-the-last-character-in-a-string

--description--

Щоб отримати останню літеру рядка, можна відняти одиницю від довжини рядка.

Наприклад, якщо const firstName = "Ada", ви можете отримати значення останньої літери, використавши firstName[firstName.length - 1].

Приклад:

const firstName = "Ada";
const lastLetter = firstName[firstName.length - 1];

lastLetter матиме значення рядка a.

--instructions--

Використайте дужкову нотацію, щоб знайти останній символ у змінній lastName.

Підказка: якщо застрягли, перегляньте вищеподаний приклад.

--hints--

lastLetterOfLastName має бути літера e.

assert(lastLetterOfLastName === 'e');

Ви повинні використати .length, щоб отримати останню літеру.

assert(__helpers.removeJSComments(code).match(/\.length/g).length > 0);

--seed--

--after-user-code--

(function(v){return v;})(lastLetterOfLastName);

--seed-contents--

// Setup
const lastName = "Lovelace";

// Only change code below this line
const lastLetterOfLastName = lastName; // Change this line

--solutions--

const lastName = "Lovelace";
const lastLetterOfLastName = lastName[lastName.length - 1];