Workshop › Text detective › Step 11 of 13

Encode a whole text

What we are doing

caesar goes through a text letter by letter, shifts each one and glues them together.

```js
function caesar(text, shift) {
  let secret = ''
  for (const letter of text.toLowerCase()) {
    secret += shiftLetter(letter, shift)
  }
  return secret
}
```

What it means

Your turn

Write caesar under shiftLetter.

Skills: Loops, Functions

All steps

  1. Read the text
  2. Count the characters
  3. Update as you type
  4. Split into words
  5. The extra-space trap
  6. An empty box has no words
  7. Count each word
  8. Drop the punctuation
  9. The most common word
  10. Shift a letter
  11. Encode a whole text
  12. The secret line
  13. Build it yourself: crack the code