To be fair to Chat-GPT you didn't mention that the units could be in feet in the list of possible input values. It would be interesting to ask it to convert that code to C++ for use with an Arduino. C++ does not allow Strings in Case statements.
You are all welcome to join our new Facebook page: https://www.facebook.com/groups/b4x.developers