Converting "feet and inches" to inches
Given an input in "feet and inches" (in the format 5' 10"), a good starting point is to pass the string and to convert the input into inches. From here, we can use the earlier formulas to convert to centimeters or metres.
The formula beneath converts "feet and inches" into inches by splitting the input value by the single quote character. It uses a regular expression to return the numeric portion of both parts of the split output. The first part of the split output represents the feet value, and the last part represents the inches. We derive the final output by multiplying the feet value by 12 and adding the inches.
(feetVal * 12) + inchesVal