Implement atoi() — JavaScript medium interview problem
Implement the `myAtoi(string s)` function, which converts a string to a 32-bit signed integer. Rules (simplified LeetCode): 1. Read and ignore leading whitespace. 2. Check for optional `+` or `-`. 3. Read digits until a non-digit; ignore the rest. 4. Convert digits; clamp into 32-bit signed range `[-2³¹, 2³¹ - 1]`. 5. If no digits, return 0. Example: `myAtoi(" -42")` → `-42`.
Tags: parsing, edge-cases
Practice this Strings problem free in the JS Interview Playground with automated tests and unlockable solutions.