-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgrasshopper-debug.js
More file actions
31 lines (25 loc) · 1.03 KB
/
grasshopper-debug.js
File metadata and controls
31 lines (25 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Debug celsius converter
// 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
}
const result = weatherInfo(31);
console.log(result);