Quality Assurance Projects - Metric-Imperial Converter

Tell us what’s happening:
I pass all the FCC tests except for these two:

  • You can use fractions, decimals or both in the parameter (i.e., 5, 1/2, 2.5/6), but if nothing is provided it will default to 1.
  • 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.

Console output display:

  • [Error: expected ‘1.60934’ to be a number]
  • [Error: expected ‘3.21868’ to be a number]

GitHub URL : GitHub - MHG-16/boilerplate-project-metricimpconverter: A boilerplate for a freeCodeCamp project.
Sandbox URL : CodeSandbox - CodeSandbox
solution: https://0z4jjb-3000.p.csb.app

Your browser information:

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

Challenge: Quality Assurance Projects—Metric-Imperial Converter

Link to the challenge:

Hi. The functional links provided didn’t seem to work, but the errors you pasted are stating that it was expecting a number, but instead got a string. I checked your code, and it seems in your convert function you are using .toFixed() to return your numbers. If you look at the manual for .toFixed() it says that it converts your number into a string… I would guess that’s your issue.

FROM: Number.prototype.toFixed() - JavaScript | MDN



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