Completed seventh exercise

This commit is contained in:
octopusGarden 2022-10-25 14:30:50 -04:00
parent 06b0bc8a26
commit 765dc7031a
1 changed files with 11 additions and 3 deletions

View File

@ -1,9 +1,17 @@
const ftoc = function() {
const ftoc = function(fnum) {
//formula to convert f to c
let cnum = (fnum - 32) * 5 % 9;
//round to one decimal
let roundCnum = parseInt(cnum.toFixed(1));
return roundCnum;
};
const ctof = function() {
//formula to convert c to f
let fnum = (cnum * 9/5) + 32;
//round to one decimal
let roundFnum = parseInt(fnum.toFixed(0));
return roundFnum;
};
// Do not edit below this line