UNPKG

conversion-package

Version:

In this package I created 4 functions which know how to convert

50 lines (37 loc) 1.17 kB
// In this package I created 4 functions which know how to convert: // __unit of length__: // inch to cm // cm to inch // __Scale of temperature__: // fahrenheit to celsius // celsius to fahrenheit // A function that converts inch to cm function inch_to_cm(inch){ let cm = inch * 2.54; console.log(`The result is:`); console.log(`inch: ${inch} ===` + ` cm: ${cm}`); } // A function that converts cm to inch function cm_to_inch(cm){ let inch = cm / 2.54; console.log(`The result is:`); console.log(`cm: ${cm} ===` + ` inch: ${inch}`); } // A function that converts fahrenheit to celsius function fahrenheit_to_celsius(Tf){ let Tc = (5 * (Tf - 32)) / 9; console.log(`The result is:`); console.log(`fahrenheit: ${Tf} ===` + ` celsius: ${Tc}`); } // A function that converts celsius to fahrenheit function celsius_to_fahrenheit(Tc){ let Tf = ((9 * (Tc)) / 5) + 32; console.log(`The result is:`); console.log(`celsius: ${Tc} ===` + ` fahrenheit: ${Tf}`); } module.exports = { inch_to_cm, cm_to_inch, fahrenheit_to_celsius, celsius_to_fahrenheit }