I have successfully converted the kelvin temp to celsius and fahrenheit for the local weather project, but I am currently unable to display a conversion to a button. What is the best way to do this? Here is the code I’m working with:
Javascript:
var temp = json.main.temp;
function kelvinToC(temp) {
var cel = temp - 273.15;
return cel;
}
var celTemp = Math.floor(kelvinToC(temp)) ;
function celsiusToF(celTemp){
var fah = ((celTemp * 9)/5 ) + 32;
return fah;
}
var fahTemp = Math.floor(celsiusToF(celTemp));
$(’#one’).click(function(){
return fahTemp;
});
HTML:
***NOTE: The html for the buttons won’t display for some reason, but I had two basic bootstrap buttons, one for fahrenheit and one for celsius. I would like to output the respective celsius and fahrenheit conversions to the respective buttons.
If you would like to see all the code for this project, here is the link:
The conversions work correctly, I just can’t get them posted to the buttons.
Thanks!