forked from wdi-sg/temperature_converter
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
35 lines (27 loc) · 1.03 KB
/
script.js
File metadata and controls
35 lines (27 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
32
33
34
35
while (true) {
var temperature = prompt("What is the temperature??");
if (temperature == "Stop") {
console.log ("Stop liao.")
break;
}
var temperatureUnit = prompt("What is the temperature Unit??");
var temperature = parseInt(temperature);
if (temperatureUnit == "Fahrenheit") {
temperatureFahr = temperature;
temperatureCels = temperature - 32;
temperatureKelv = temperature + 241.15;
console.log (temperatureFahr + "\xB0 F = " + temperatureCels + "\xB0C = " + temperatureKelv + "K");
} else if (temperatureUnit == "Celsius") {
temperatureCels = temperature;
temperatureFahr = temperature + 32;
temperatureKelv = temperature + 273.15;
console.log (temperatureFahr + "\xB0 F = " + temperatureCels + "\xB0C = " + temperatureKelv + "K");
} else if (temperatureUnit == "Kelvin") {
temperatureKelv = temperature;
temperatureCels = temperature - 273.15;
temperatureFahr = temperature - 241.15;
console.log (temperatureFahr + "\xB0 F = " + temperatureCels + "\xB0C = " + temperatureKelv + "K");
} else {
console.log ("No such Unit!!");
}
}