-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdebug.js
23 lines (16 loc) · 908 Bytes
/
debug.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/*
Your friend is traveling abroad to the United States so he wrote a program to convert fahrenheit to celsius. Unfortunately his code has some bugs.
Find the errors in the code to get the celsius converter working properly.
To convert fahrenheit to celsius:
celsius = (fahrenheit - 32) * (5/9)
Remember that typically temperatures in the current weather conditions are given in whole numbers. It is possible for temperature sensors to report temperatures with a higher accuracy such as to the nearest tenth. Instrument error though makes this sort of accuracy unreliable for many types of temperature measuring sensors.
*/
function weatherInfo(temp) {
var c = convertToCelsius(temp);
if (c < 0) return c + ' is freezing temperature';
else return c + ' is above freezing temperature';
}
function convertToCelsius(temperature) {
var celsius = (temperature - 32) * (5 / 9);
return celsius;
}