Metric-Imperial Converter problem

Hi. I cant seem to find the solution of my problem. I cant get pass these 2 tests :

If the number is invalid, returned will be ‘invalid number’

If both the unit and number are invalid, returned will be ‘invalid number and unit’

All other tests are running fine, I just dont know what to do.

Link to the solution: Glitch :・゚✧

Were you able to find a solution? I’m having the same issue right now.

If I pass the input of 1//2mi to your app, it should return invalid number. Instead, you return {"initNum":0.5,"initUnit":"mi","returnNum":0.80467,"returnUnit":"km","string":"0.5 miles converts to 0.80467 kilometers"}.

Another example is if I pass e1mi, it should return invalid number. Instead you return "invalid unit".

There are two issues going on here. First, your logic is not correctly determining when to realize an invalid number has been passed. The other issue, is that you are using res.json() instead of res.send(). To pass back just a string response, you should use res.send().

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