Metric-Imperial Converter Project fails

Tell us what’s happening:
Once I run my project for test cases it fails on 2 cases, which pass without any problem when I manually check it. Could you please test the below project
Your project link(s)
Here is the repl source code:project source


Your browser information:

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

Challenge: Metric-Imperial Converter

Link to the challenge:

Could you run test with opening Chrome Developer tool?
Maybe you can find two error messages at JavaScript console, like this:

frame-runner.js:98 Error: expected '1.60934' to be a number
    at eval (eval at <anonymous> (frame-runner.js:84), <anonymous>:24:11)

This is because your return value, returnNum, should not be String but Number.
Since these 2 tests use the assert.approximately(...) statement, returnNum is expected to be a number.

Ref. freeCodeCamp/curriculum/challenges/english/06-quality-assurance/quality-assurance-projects/ at 73e5c4d935578e76c01e0248a7e6d042c99fb52b · freeCodeCamp/freeCodeCamp · GitHub

Here is one of the workaround.

     // Values can be converted to numbers using the Number() function.
     returnNum = Number(returnNum);


The other test statements accept the string value (exp. “123”, “234”), so I think it would be nice that above 2 test explicitly convert the type (string to number) :slight_smile:

1 Like

Many thanks, just converting the return string to number solved the issue.

1 Like

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