Skip to content

YAGIRO practice

Find what trimming leaves on a divider tab

Two ends, one interior space and a zero-width space give different results. A drawer survey also explains why a new empty string deserves a second look.

Read the positions in the drawer

Open the fictional survey T4 and paste keys.json into the key preview. Rows 1 through 5 transcribe five divider positions. The array writes unusual characters as JSON escapes.

Select none first. The seven original strings are distinct. Row 6 holds one ordinary space and row 7 holds zero characters. Only row 7 counts as empty.

Trim the edges

Run trim. Row 1 loses ordinary spaces at its ends. Row 3 loses the leading U+00A0 NO-BREAK SPACE. They join row 2, which already held TAB-4.

Look at row 4 between the B and the hyphen. Its interior space remains. Row 5 ends in U+200B ZERO WIDTH SPACE, which JavaScript trim also leaves in place.

Account for both new groups

Row 6 becomes empty. Rows 6 and 7 form a second output group. In expected.json, the empty count rises from one to two and the distinct count falls from seven to four.

Only rows 1, 3 and 6 changed. The row-by-row literal spellings let you distinguish the trailing U+200B from a plain ending even if two strings look alike.

Interpret the blank entries

The operator marked row 6 unreadable. Row 7 was reserved for a divider that had not arrived. An empty result after trimming carries neither explanation by itself.

Retain those two source notes with their positions. For the other group the survey gives no permanent divider IDs. A shared trimmed string is insufficient to identify one physical divider.

Files for this exercise

Fictional text and JSON string arrays. Follow the guide to choose an input and operation. Keep the original and compare the expected report with your result.

Reference sources

Continue with a check