Lesson 01-01

First Green Test

10 min
1 export
3 tests

Lesson workspace sections

Submission + Results
Not run yet

Seed 101
Test Results

Run tests to see case-by-case feedback.

Attempts0 saved

No saved attempts yet.

Lesson README

01-01 First Green Test

Why this matters

Text normalization prevents artificial vocabulary inflation from casing and spacing artifacts, so downstream counts represent real language patterns.

Intuition first (no jargon)

Before any model logic, make equivalent text map to the same normalized string.

Code walkthrough

You will implement:

js
export function normalizeText(text) {
  // lowercase and trim extra edges
}

Your task

Implement normalizeText(text).

  • Convert to lowercase.
  • Trim spaces at the start and end.
  • Collapse internal repeated spaces to one space.

Hints

  • String(text) helps with unexpected inputs.
  • toLowerCase() handles casing.
  • A regex like /\s+/g can collapse repeated spaces.

Check your thinking

  1. Why is consistent casing useful for learning patterns?
  2. What changes if you do not trim text first?
  3. Should punctuation be removed in this lesson?

Stretch (optional)

Preserve newlines while still collapsing repeated spaces inside each line.

Likely test focus

  • Returns lowercase output.
  • Removes leading and trailing whitespace.
  • Collapses repeated internal spaces.

What should improve

Your preprocessing step now yields stable, repeatable input for counting and modeling.

Bridge to next lesson

Now that text is clean, you can count what the model actually sees.

Monaco Editor

Matches starter

Files

Editor is deferred on smaller screens to keep startup fast.

Autosave is enabled in local storage for this lesson.