forked from wdi-sg/temperature_converter
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript5.js
More file actions
29 lines (20 loc) · 808 Bytes
/
script5.js
File metadata and controls
29 lines (20 loc) · 808 Bytes
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
/*
use while (typeof temperatureUnit === "number") {
}
var starting_temp = parseInt(prompt("Enter a temperature"));
var temperatureUnit = prompt("What is the unit of the temperature? (fahrenheit, celsius or kelvin)")
if (temperatureUnit === "fahrenheit") {
var converted_temp_1 = (starting_temp - 32) * (5/9);
var converted_temp_2 = ((starting_temp - 32) * 5/9) + 273.15;
} else if (temperatureUnit === "celsius") {
var converted_temp_1 = (starting_temp * 9/5) + 32;
var converted_temp_2 = starting_temp + 273.15;
} else if (temperatureUnit === "kelvin") {
var converted_temp_1 = ((starting_temp-273.15)*9/5)+32;
var converted_temp_2 = starting_temp - 273.15;
} else {
console.log("Unit is invalid")
}
var temps = [ starting_temp, converted_temp_1, converted_temp_2 ];
console.log(temps);
*/