-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
67 lines (63 loc) · 2.84 KB
/
script.js
File metadata and controls
67 lines (63 loc) · 2.84 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
function control(){
let startingScale = document.getElementById("scale").value;
if(startingScale === 'Fahrenheit'){
fahrenheitFunction();
}
else if(startingScale === 'Celsius'){
celsiusFunction();
}
else if (startingScale === 'Kelvin'){
kelvinFunction();
}
else if (startingScale === 'Rankine'){
rankineFunction();
}
}
// this is celsius to other stuff
function celsiusFunction(){
let tempToConvert = parseInt(document.getElementById("textBox").value);
let convertToFahrenheit = (tempToConvert * 9/5) + 32;
let convertToCelsius = tempToConvert;
let convertToKelvin = tempToConvert + 273.15 ;
let convertToRankine = tempToConvert * 9/5 + 491.67;
document.getElementById("fahrenheit").innerHTML = convertToFahrenheit;
document.getElementById("temp").innerHTML = convertToCelsius;
document.getElementById("to-kelvin").innerHTML = convertToKelvin;
document.getElementById("to-rankine").innerHTML = convertToRankine;
}
// this it fahrenheit to other stuff
function fahrenheitFunction(){
let tempToConvert = parseInt(document.getElementById("textBox").value);
let convertToCelsius = (tempToConvert - 32) * 5/9;
let convertToFahrenheit = tempToConvert;
let convertToKelvin = (tempToConvert - 32) * 5/9 + 273.15;
let convertToRankine = tempToConvert + 459.67;
document.getElementById("temp").innerHTML = convertToCelsius;
document.getElementById("fahrenheit").innerHTML = convertToFahrenheit;
document.getElementById("to-kelvin").innerHTML = convertToKelvin;
document.getElementById("to-rankine").innerHTML = convertToRankine;
}
// this is kelvin to other stuff
function kelvinFunction(){
let tempToConvert = parseInt(document.getElementById("textBox").value);
let convertToCelsius = tempToConvert - 273.15;
let convertToFahrenheit = (tempToConvert - 273.15) * 9/5 + 32;
let convertToKelvin = tempToConvert;
let convertToRankine = tempToConvert * 1.8;
document.getElementById("temp").innerHTML = convertToCelsius;
document.getElementById("fahrenheit").innerHTML = convertToFahrenheit;
document.getElementById("to-kelvin").innerHTML = convertToKelvin;
document.getElementById("to-rankine").innerHTML = convertToRankine;
}
// this is rankine to other stuff
function rankineFunction(){
let tempToConvert = parseInt(document.getElementById("textBox").value);
let convertToCelsius = (tempToConvert - 491.67) * 5/9;
let convertToFahrenheit = tempToConvert - 459.67;
let convertToKelvin = tempToConvert * 5/9;
let convertToRankine = tempToConvert;
document.getElementById("temp").innerHTML = convertToCelsius;
document.getElementById("fahrenheit").innerHTML = convertToFahrenheit;
document.getElementById("to-kelvin").innerHTML = convertToKelvin;
document.getElementById("to-rankine").innerHTML = convertToRankine;
}