Metric-Imperial Converter - tests not passing

I am currently working on the Metric-Imperial Converter, from the archived curriculum.

I’ve built a function converter that appears to work correctly. The front-end matches the example app (https://metric-imperial-converter.freecodecamp.rocks/), and I can perform conversions successfully.

However, only the first two tests are passing in the test suite. I’m not sure what I’m missing in the implementation.

**Links**

Could anyone help me understand what might be causing the tests to fail? Any guidance would be greatly appreciated.

Thank you.

Hi @sglavas

Please share your output for 1gal.

Happy coding

1 Like

Hello, Teller.

This is the output for 1gal:

1 gallons converts to 3.78541 liters

{"initNum":1,"initUnit":"gal","returnNum":3.78541,"returnUnit":"L","string":"1 gallons converts to 3.78541 liters"}

It appears to be identical to the example app.

Hi @sglavas

How about 1L?

Happy coding

Hello.

This is the output for 1L:

1 liters converts to 0.26417 gallons

{"initNum":1,"initUnit":"L","returnNum":0.26417,"returnUnit":"gal","string":"1 liters converts to 0.26417 gallons"}

Try using .toFixed() instead of math.round().

I’ve changed convertHandler.js from

let roundedNumber = math.round(result.toNumber(), 5);

to

    let roundedNumber = result.toFixed(5);

However, I’m still not passing the tests from 3 to 13.

**Link**

.toFixed() returns a string.

Try converting it to a number.

I’ve changed convertHandler.js from

let roundedNumber = result.toFixed(5);

to

let roundedNumber = Number(result.toFixed(5));

It should be a number now.

However, still no progress.

**Link**