---
id: 69bc6cb30c1d112a2e110a04
title: "Challenge 247: Last Letter"
challengeType: 28
dashedName: 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"`.

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

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

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

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

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

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

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

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

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

# --seed--

## --seed-contents--

```js
function getLastLetter(str) {

  return str;
}
```

# --solutions--

```js
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);
}
```
