← All Exercises
Classify Fields by Data Sensitivity
basicjavascript
Background
Privacy policy is enforced per field category. Classifying by sample value exposes fields that were named innocuously but hold regulated data.
Problem
Given sampled field values, label each field as email, payment-card, government-id, date-of-birth, or none, so downstream storage and retention rules can be applied.
Input
JSON object: { fields: [{ name, sample }] }Output
JSON array of { name, category } in input orderSample tests
Sample 1
Input: {"fields":[{"name":"contact","sample":"[email protected]"},{"name":"card_on_file","sample":"4111 1111 1111 1111"},{"name":"notes","sample":"likes tea"}]}Expected: [{"name":"contact","category":"email"},{"name":"card_on_file","category":"payment-card"},{"name":"notes","category":"none"}]Sample 2
Input: {"fields":[{"name":"ssn","sample":"123-45-6789"},{"name":"dob","sample":"1990-01-01"}]}Expected: [{"name":"ssn","category":"government-id"},{"name":"dob","category":"date-of-birth"}]Your solution
Learning objective
Detect regulated data from field samples before it reaches storage.