programming-examples/js/Basic/Write a JavaScript program to convert temperatures to and from celsius, fahrenheit..js

17 lines
414 B
JavaScript
Raw Normal View History

2019-11-18 14:44:36 +01:00
function cToF(celsius)
{
var cTemp = celsius;
var cToFahr = cTemp * 9 / 5 + 32;
var message = cTemp+'\xB0C is ' + cToFahr + ' \xB0F.';
console.log(message);
}
function fToC(fahrenheit)
{
var fTemp = fahrenheit;
var fToCel = (fTemp - 32) * 5 / 9;
var message = fTemp+'\xB0F is ' + fToCel + '\xB0C.';
console.log(message);
}
cToF(60);
fToC(45);