---
id: 699d20623e57e8ffee885455
title: Step 5
challengeType: 1
dashedName: step-5
---

# --description--

As you can see from the output in the console, after splitting, each part still has extra leading and/or trailing whitespace. To clean every element, you need to process each one individually.

This is a perfect use case for a `for` loop, which repeats a block of code once for each element in an iterable, such as an array:

```js
for (let i = 0; i < array.length; i++) {
  // code to run on each iteration
}
```

`i` starts at `0` (the first index), the loop continues while `i` is less than the array's length, and `i++` increases `i` by one after each iteration.

Inside `parseCard`, declare an empty array named `trimmedParts`. Then add a `for` loop that iterates over `parts`. Leave the loop body empty for now, as you'll fill it in the next step.

# --hints--

You should declare a variable named `trimmedParts` set to an empty array.

```js
assert.match(parseCard.toString(), /(const|let|var)\s+trimmedParts\s*=\s*\[\s*\]/);
```

You should use a `for` loop to iterate over `parts`.

```js
assert.match(parseCard.toString(), /for\s*\(\s*(var|let)\s+(\w+)\s*=\s*0\s*;\s*\2\s*<\s*parts\s*\.\s*length\s*;\s*\2\+\+\s*\)\s*\{/);
```

# --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("|");
--fcc-editable-region--

--fcc-editable-region--
  return parts;
}

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