Closures & Functions

Implement Unary Function Adapter

easyJS SpecificJS / TS3 tests

Problem Statement

Implement `unary(fn)`, which creates a function that accepts up to one argument, ignoring any additional arguments. This prevents common bugs like `['1', '2', '3'].map(parseInt)`.

Examples

Example 1:
['1', '2', '3'].map(unary(parseInt)); // [1, 2, 3] (instead of [1, NaN, NaN])
JavaScript & TypeScript starter code included
Run this as a live interview

Practice solo

3 test cases. No second person needed.

Get new interview exercises

Practice problems and review drills, sent when we publish new ones. No spam.

Unsubscribe anytime. We never share your address.