Quality Assurance Projects - Metric-Imperial Converter

Tell us what’s happening:

I’ve passed all the tests locally and every thing works fine but in the freecodecamp submission test 5 doesn’t pass
5. You can convert ‘mi’ to ‘km’ and vice versa. (1 mi to 1.60934 km)

###Your project link(s)

solution: http://localhost:3000

githubLink: GitHub - knokhen/Fcc-Metric-Imperial-Converter

Your browser information:

User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36

Challenge Information:

Quality Assurance Projects - Metric-Imperial Converter

Welcome to the forum @knokhen

What is the output when you enter 1 mi, and 1 km into the converter?

Happy coding

1 Like

mi outputs:
1 miles converts to 1.60934 kilometers

{"initNum":1,"initUnit":"mi","returnNum":1.60934,"returnUnit":"km","string":"1 miles converts to 1.60934 kilometers"}

km outputs:
1 kilometers converts to 0.62137 miles

{"initNum":1,"initUnit":"km","returnNum":0.62137,"returnUnit":"mi","string":"1 kilometers converts to 0.62137 miles"}

The result looks correct.
However since the test is failing, try refactoring to remove 1e5.

Happy coding

1 Like

turns out I need to round the number instead of flooring