Files
freecodecamp--freecodecamp/curriculum/challenges/english/blocks/daily-coding-challenges-javascript/69bc6cb30c1d112a2e110a04.md
T
wehub-resource-sync 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
chore: import upstream snapshot with attribution
2026-07-13 11:55:53 +08:00

1.3 KiB

id, title, challengeType, dashedName
id title challengeType dashedName
69bc6cb30c1d112a2e110a04 Challenge 247: Last Letter 28 challenge-247

--description--

Given a string, return the letter from the string that appears last in the alphabet.

  • If two or more letters tie for the last in the alphabet, return the first one.
  • Ignore all non-letter characters.

--hints--

getLastLetter("world") should return "w".

assert.equal(getLastLetter("world"), "w");

getLastLetter("Hello World") should return "W".

assert.equal(getLastLetter("Hello World"), "W");

getLastLetter("The quick brown fox jumped over the lazy dog.") should return "z".

assert.equal(getLastLetter("The quick brown fox jumped over the lazy dog."), "z");

getLastLetter("HeLl0") should return "L".

assert.equal(getLastLetter("HeLl0"), "L");

getLastLetter("!#$ er@R asd fT.,> 2t0e9") should return "T".

assert.equal(getLastLetter("!#$ er@R asd fT.,> 2t0e9"), "T");

--seed--

--seed-contents--

function getLastLetter(str) {

  return str;
}

--solutions--

function getLastLetter(str) {
  const letters = str.split('').filter(char => /[a-zA-Z]/.test(char));
  return letters.reduce((last, char) => char.toLowerCase() > last.toLowerCase() ? char : last);
}