Redondear | .floor - convertir
Sun Oct 10 2021 22:07:47 GMT+0000 (Coordinated Universal Time)
Saved by
@ianvalentino
#javascript
/* The forecast today is 293 Kelvin */
const kelvin = 300;
/* We convert Kelvin to Celsius; */
/* Celsius is 273 degrees less than Kelvin */
const celsius = kelvin - 273;
/* We convert Celsius to Fahrenheit using a equation */
let fahrenheit = celsius * (9/5) + 32
/* .floor() method from the built-in Math object to round down the Fahrenheit temperature */
fahrenheit = Math.floor(fahrenheit);
let newtonscale = celsius * (33/100);
newtonscale = Math.floor(newtonscale);
console.log(`The temperature is ${fahrenheit} degrees Fahrenheit.`);
console.log(`The temperature Newton is ${newtonscale} degrees.`);
content_copyCOPY
Deep in his mountain-side meteorology lab, the mad scientist Kelvin has mastered weather prediction.
Recently, Kelvin began publishing his weather forecasts on his website. However there’s a problem: All of his forecasts describe the temperature in Kelvin.
With our knowledge of JavaScript, let’s convert Kelvin to Celsius, then to Fahrenheit.
https://www.codecademy.com/courses/introduction-to-javascript/projects/kelvin-weather-javascript
Comments