This is my code:
function convertFahrToCelsius(temp) {
if(typeof(temp) === "number" || typeof(temp) === "string"){
return ((Number(temp) - 32) * 5/9).toFixed(4);
} else {
return `${temp} is not a valid number but a/an ${typeof(temp)}`;
}
}
console.log(convertFahrToCelsius(0));
console.log(convertFahrToCelsius("0") );
console.log(convertFahrToCelsius([1,2,3]));
console.log(convertFahrToCelsius({temp: 0}));
This should be the output:
- convertFahrToCelsius(0) should return `-17.7778`
- convertFahrToCelsius("0") should return `-17.7778`
- convertFahrToCelsius([1,2,3]) should return `[1,2,3] is not a valid number but a/an array.`
- convertFahrToCelsius({temp: 0}) should return `{temp: 0} is not a valid number but a/an object.`
This is my ouput:
- convertFahrToCelsius(0);: -17.7778
- convertFahrToCelsius("0");:-17.7778
- convertFahrToCelsius([1,2,3]);:1,2,3 is not a valid number but a/an object
- convertFahrToCelsius({temp: 0});:[object Object] is not a valid number but a/an object
I need the last two outputs to be the same as it should be.