dde272c4b8
i18n - Build Validation / Validate i18n Builds (24) (push) Has been cancelled
CI - Node.js / Lint (24) (push) Has been cancelled
CI - Node.js / Build (24) (push) Has been cancelled
CI - Node.js / Test (24) (push) Has been cancelled
CI - Node.js / Test - Upcoming Changes (24) (push) Has been cancelled
CI - Node.js / Test - i18n (italian, 24) (push) Has been cancelled
CI - Node.js / Test - i18n (portuguese, 24) (push) Has been cancelled
CD - Docker - GHCR Images / Build and Push Images (push) Has been cancelled
1.4 KiB
1.4 KiB
id, title, challengeType, forumTopicId, dashedName
| id | title | challengeType | forumTopicId | dashedName |
|---|---|---|---|---|
| bd7123c9c452eddfaeb5bdef | Use Bracket Notation to Find the Nth-to-Last Character in a String | 1 | 18344 | use-bracket-notation-to-find-the-nth-to-last-character-in-a-string |
--description--
You can use the same principle we just used to retrieve the last character in a string to retrieve the Nth-to-last character.
For example, you can get the value of the third-to-last letter of the const firstName = "Augusta" string by using firstName[firstName.length - 3]
Example:
const firstName = "Augusta";
const thirdToLastLetter = firstName[firstName.length - 3];
thirdToLastLetter would have a value of the string s.
--instructions--
Use bracket notation to find the second-to-last character in the lastName string.
Hint: Try looking at the example above if you get stuck.
--hints--
secondToLastLetterOfLastName should be the letter c.
assert(secondToLastLetterOfLastName === 'c');
You should use .length to get the second last letter.
assert(__helpers.removeJSComments(code).match(/\.length/g).length > 0);
--seed--
--seed-contents--
// Setup
const lastName = "Lovelace";
// Only change code below this line
const secondToLastLetterOfLastName = lastName; // Change this line
--solutions--
const lastName = "Lovelace";
const secondToLastLetterOfLastName = lastName[lastName.length - 2];