2 tests won't pass on QA Metric Imperial Converter need help

Tell us what’s happening:
I’ve been working on this project for days now. I started this project locally and got all the unit and functional tests to pass. But when uploading my url in FCC it won’t pass 2 tests:

All incoming units should be accepted in both upper and lower case, but should be returned in both the initUnit and returnUnit in lower case, except for liter, which should be represented as an uppercase 'L'.

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.

I’m not sure how to go about the first one. Tried adding .toUpperCase/.toLowerCase instances originally and nothing worked. Maybe I just had them in wrong spots, but IDK.

I’m not sure how the last one doesn’t pass, it works for me and never shows more than 5 decimals. Unless they want it to show 5 decimals at all times (e.g. 4/2 = 2.00000 instead of 2). Any help getting these 2 tests to pass is greatly appreciated!

Here’s the link to my project : https://jjmason-metricimpconverter.rookiebehaviour.repl.co

Your code so far

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.146 Safari/537.36.

Challenge: Metric-Imperial Converter

Link to the challenge:

1 Like

Hey, next time I think you should also copy in a part of your code, otherwise hard to troubleshoot just from the front end.

Anyway, my guess:

  1. Try to return the initial L as uppercase as well (even if you provide 1l), return the initUnit as L

  2. Return string. You are returning

"string":"1 litre(s) converts to 0.26417 gallon(s)"}

Should return:
{initNum} {initUnitString} converts to {returnNum} {returnUnitString}

as in
"string":"1 liters converts to 0.26417 gallons"
replace the (s) with s :slight_smile:

@Aigarsss
Thank you for your reply and taking the time to try to help me. I didn’t realize it showed the front-end in full screen without showing an option to see the code. As you can tell I don’t post for help much in here, lol. However, it was hard to post code, when the problems I’m having I’m not sure what file or file(s) they are coming from. So I figured it was easier to provide the whole project.

In regards to your suggestions, the parentheses around the (s) didn’t make a difference. I’m returning the json object just as you posted above. And the 1st suggestion about removing one of the l’s, I already tried that. It doesn’t like that and throws errors due to the forEach() in the unit testing. And for some reason it doesn’t like when I put two L’s. And if I make so ‘L’ is only accepted in the input then it will still fail because they want inputs to accept both upper and lower case, but return lowercase, except for ‘L’ :expressionless:

So I’m so confused and nothing I’ve tried had worked so far. Like I said, all the unit and functional tests pass, but every time I try to modify the array or add some code to get the 2 tests above to pass, it breaks and makes some of the unit/functional tests not pass. These 2 tests are so frustrating, lol.

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