How to usethe arrow function and template literals in Javascript
In this approach, we are using the arrow function and template literals to convert Celsius to Fahrenheit. The arrow function applies the formula: Fahrenheit = (Celsius * 9/5) + 32. For a given temperature of 20°C.
Syntax:
const celcToFahr = (n) => `${n} Celsius is equal to ${(n * 9 / 5) + 32} Fahrenheit.`
Example: In this example, we are using the arrow function with the formula: Fahrenheit = (Celsius * 9/5) + 32.
Javascript
const celcToFahr = (n) => `${n} Celsius is equal to ${(n * 9 / 5) + 32} Fahrenheit.`; const n = 20; console.log(celcToFahr(n)); |
Output
20 Celsius is equal to 68 Fahrenheit.
JavaScript Program to Convert Celsius to Fahrenheit
Fahrenheit and centigrade are the two most used temperature scales and we often need to convert Celsius to Fahrenheit. In this article, we are going to learn how to Convert Celsius to Fahrenheit.