Command Palette

Search for a command to run...

Hectal
Back to the lesson: Topic 2.1 — Kinds of Data
Data Visualization · Example 2 of 2

Five quiet mistakes with the wrong kind

Nothing here throws an error. Every line gives an answer that looks reasonable and is wrong.

Data comes in four kinds: quantitative (amounts), ordinal (ordered labels), categorical (unordered labels) and time. The kind decides what you may do with a column: sort it, average it, compare it, or only count it.

Change the code and press Run (Ctrl+Enter). Predict what will happen first, then break it on purpose and read what changes. Your edits are saved and match the lesson page.

Ready for more? This phase has 4 hands-on exercises with automatic checks.

Practice questions

Write the code in the editor, run it, then open the model answer to compare.

01

Write isNumberColumn(values) that returns true only if every non-empty value converts to a finite number and none starts with a zero followed by another digit (like "07790"). Test with ["12", "20"], ["07790", "09250"], ["S01", "S02"].

02

Write meanOf(values) for an array of strings that returns the mean of the numeric ones, skips empty strings and "n/a", and returns null when nothing numeric is left. Test with ["1539", "1519", "1950", "", "1915"] and ["", "n/a"].

Explain it without notes

01

Name the four kinds of data and one Lumen column for each.

02

Why is a station ID such as S01 not a number even though it contains digits?

03

Why is a missing value not the same as zero? Give a Lumen example.

Five quiet mistakes with the wrong kind

Console

(nothing was printed)

Expected console output

1. dates sorted as text: [ '13/03/2025', '2025-03-02', '2025-03-09', '2025-03-10' ]
2. weekdays sorted as text: [ 'Fri', 'Mon', 'Sat', 'Sun', 'Thu', 'Tue', 'Wed' ]
   weekdays in their real order: [ 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun' ]
3. empty cell read as a number: 0 -> mean 1384.6
   empty cell left out:          mean 1730.75
4. an ID as a number: 7790 - and back to text: 7790
5. numbers sorted without a compare function: [ 2979, 3742, 439 ]
   numbers sorted properly: [ 439, 2979, 3742 ]