Test fails on Metric-Imperial Converter Project

Your return will consist of the initNum, initUnit, returnNum, returnUnit, and string spelling out units in the format '{initNum} {initUnitString} converts to {returnNum} {returnUnitString}' with the result rounded to 5 decimals.

The above test is failing and I can’t figure out why - as far as I can see I am returning what is required. I tried moving a few things around, e.g. when rounding happens, the point at which string is defined - i.e before res.json or in res.json. Nothing seems to work!

Please can someone look at my code and help me find where this problem is coming from.

Thanks in advance!! :pray:

Your project link(s)

solution: https://replit.com/@ljmassive/boilerplate-project-metricimpconverter

Your browser information:

User Agent is: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:89.0) Gecko/20100101 Firefox/89.0

Challenge: Metric-Imperial Converter

Link to the challenge:

For the spelledOutUnit in string you are using kilometres while FCC testing suite expects kilometers.

Hope that helps.


Perfect, solved it! Thanks so much, I would never have figure that out - it’s not the first time I’ve been caught out because of American spelling - by any chance could you let me know how/if you can check exactly what FCC is testing for and/or where it is failing?

Happy you solved it!
I’m quite not sure anymore how I found this one but there are two approaches that I’m aware of:
1- Testing against the sample solution to see what the expected output is. This method doesn’t always help because there are test which you don’t know the specifics of.
2- Going through FCC’s website. FCC’s whole curriculum, including the challenges and projects, is open source which you can find here. This specific project is located here. You can either read through the tests or even setup the website locally and run it.

Personally, I find that this second approach, while some may consider it not honest, has helped me a lot in reading, searching and learning.

Hope that helps.

This is so helpful! Thank you for sharing it with me.

I understand what you mean, but I think if you are using it to figure out where things are going wrong and to learn, it’s ok. Sometimes the user stories are not specific enough about what is required to actually make the test pass!

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.