Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script src="script.js"></script>
</head>
<body>

</body>
</html>
<!DOCTYPE>
<html>
<head>
<title>Temperature Exercise</title>
</head>
<body>
<p>Temperature conversion</p>
</body>
<script src="script.js"></script>
</html>
36 changes: 36 additions & 0 deletions script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//Part 1
var temperatureInFahr = prompt('Key in Temperature');//Prompt temperature in F
var tempF=parseInt(temperatureInFahr)// Conver str to int
var tempD=(tempF-32)/1.8; // Convertion of F to C
console.log('The fahrenheit is'+' '+ tempF); //Print Fahrenheit
console.log('The degree is'+' '+ tempD); //Print Degree
//Part 2
var temp = prompt('Key in temperature');//value entered in degree
var temperature = parseInt(temp)//convert str to int
var temperatureUnit = prompt('Choose Fahrenheit, Celsius or Kelvin');


var fahrenheit=function(){
var valueF = (temperature*1.8)-32;
console.log('The fahrenheit is'+' '+ valueF);
}
var celsius=function(){
console.log('The degree is'+' '+temperature);
}
var kelvin=function(){
var valueK = temperature + 273.15;
console.log('The kelvin is'+' '+ valueK)
}

if (temperatureUnit=='Faherenheit'){
celsius();
kelvin();
}else if(temperatureUnit=='Celsius'){
fahrenheit();
kelvin();
}else if(temperatureUnit=='Kelvin'){
fahrenheit();
celsius();
}else{
alert('Error, invaild request');
}