logo CodeStepByStep logo

inchesToCentimeters

Language/Type: JavaScript basics expressions variables

Write a function named inchesToCentimeters that takes two parameters: a number of feet (ft) and a number of inches (in). The function should convert these values into centimeters and return the result. Note that there are 2.54 centimeters per inch, and 12 inches per foot.

For example, the call inchesToCentimeters(5, 11) should return 180.34 (from (5 * 12 + 11) * 2.54).

If either argument passed is negative, throw an exception with the message, "values for feet and inches must be non-negative".

Function: Write a JavaScript function as described, not a complete program.

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.