---
id: 699d20623e57e8ffee885457
title: Step 8
challengeType: 1
dashedName: step-8
---

# --description--

Some catalog cards have missing fields. For example, entry 16 has a blank author, so `parseCard` currently returns an empty string for that field.

The `||` operator provides a fallback: `a || b` evaluates to `a` when `a` is truthy, and `b` otherwise. Since an empty string is falsy, `"" || "Unknown"` evaluates to `"Unknown"`.

Update `title`, `author`, and `location` in the return statement to use `|| "Unknown"` as a fallback. Leave `year` for the next step.

# --hints--

When called with a string that has a blank author field, the `author` property of the returned object should be `"Unknown"`.

```js
assert.strictEqual(parseCard("X |  | 2000 | Y").author, "Unknown");
```

When called with a string that has a blank title field, the `title` property of the returned object should be `"Unknown"`.

```js
assert.strictEqual(parseCard(" | A | 2000 | Y").title, "Unknown");
```

When called with a string that has a blank location field, the `location` property of the returned object should be `"Unknown"`.

```js
assert.strictEqual(parseCard("X | A | 2000 | ").location, "Unknown");
```

You should not add a fallback for `year` yet.

```js
assert.strictEqual(parseCard("X | A |  | Y").year, "");
```

When all fields are present, `parseCard` should return their actual values and not `"Unknown"`.

```js
assert.strictEqual(parseCard("The Stand | King, Stephen | 1978 | Shelf K2").title, "The Stand");
```

# --seed--

## --seed-contents--

```js
const rawCatalogCards = [
  "From a Buick 8 | King, Stephen | 2002 | Shelf K7",
  "The Shining | King, Stephen | 1977 | Shelf K1",
  "The Stand | King, Stephen | 1978 | Shelf K2",
  "It | King, Stephen | 1986 | Shelf K3",
  "Misery | King, Stephen | 1987 | Shelf K4",
  "Do Androids Dream of Electric Sheep? | Dick, Philip K. | 1968 | Shelf D5",
  "I, Robot | Asimov, Isaac | 1950 | Shelf A8",
  "Foundation | Asimov, Isaac | 1951 | Shelf A9",
  "Dune | Herbert, Frank | 1965 | Shelf H3",
  "Neuromancer | Gibson, William | 1984 | Shelf G8",
  "Snow Crash | Stephenson, Neal | 1992 | Shelf S6",
  "The Martian | Weir, Andy | 2011 | Shelf W5",
  "Ender's Game | Card, Orson Scott | 1985 | Shelf C2",
  "The Hitchhiker's Guide to the Galaxy | Adams, Douglas | 1979 | Shelf A1",
  "Ready Player One | Cline, Ernest | 2011 | Shelf C7",
  "The Dark Tower: The Gunslinger | King, Stephen | 1982 | Shelf K5",
  // edge cases: missing data
  "Unknown Title |  | 1975 | Shelf X1",
  "Mysterious Manuscript | Unknown Author |  | Shelf Z9",
  "Ancient Scroll | Anonymous | 850 | ",
];

function parseCard(rawString) {
  const parts = rawString.split("|");
  const trimmedParts = [];
  for (let i = 0; i < parts.length; i++) {
    trimmedParts.push(parts[i].trim());
  }
  const title = trimmedParts[0];
  const author = trimmedParts[1];
  const year = trimmedParts[2];
  const location = trimmedParts[3];
--fcc-editable-region--
  return {
    title: title,
    author: author,
    year: year,
    location: location
  };
--fcc-editable-region--
}

const cardResult = parseCard(rawCatalogCards[2]);
console.log(cardResult);
```
