Fundamentals Part 4: Why doesn't this work for tempConversion?


#1

For converting a Fahrenheit temperature to Celcius, can someone explain why my code isn’t passing the tests? I don’t believe I’ve gotten the actual math wrong, so I’m assuming it’s something about how I’m calling the toFixed method, but I’m not sure what.

  const ftoc = function(tempFahrenheit) {
			let convertedTemp = 5/9 * (tempFahrenheit - 32);
			return Number(convertedTemp).toFixed(1);
		}

#2

What output are you getting from the tests?


#3

I believe you are accidentally returning a string instead of a number.

Try changing

return Number(convertedTemp).toFixed(1);

to

return Number(convertedTemp.toFixed(1));

and see if that fixes your problem :wink: