Question: Write a temperature converter in javascript. Inside of the file Temperature.ts class create a class Temperature The Temperature class: Should have 3 fields defined, celcius,
Write a temperature converter in javascript.
Inside of the file Temperature.ts class create a class Temperature
The Temperature class:
Should have 3 fields defined, celcius, fahrenheit, and kelvin
Should have a constructor that takes 2 arguments, unit and temp
Based on the unit it it should use the conversion formulas above to set all the fields to the correct temperature. All of the conversion work should happen in the constructor. Hint:
After your temperature class create an instance of the temperature class and console.log the fahrenheit, celsius, and kelvin temperatures. Example:
const temp = new Temperature("fahrenheit", -40);
console.log(temp.celcius);
console.log(temp.kelvin);
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
