Kelvin weather project - HELP


This is my code (minus comments):

const kelvin = 294;
const Celcius = Kelvin - 273;
let fahrenheit = Celcius * (9/5) + 32;
console.log(fahrenheit = Math.floor(fahrenheit));
console.log(“The temperature is ${fahrenheit} degrees fahrenheit”);
console.log(const kelvin = prompt(‘What is the Kelvin temperature today?’);

I get the "SyntaxError: Unexpected token const"
What’s wrong with “const” keyword?


Don’t log that expression, just declare it.

Likewise above. Don’t log this. Use the expression to replace the first line of the program, as the instructions indicate.


Thank you! However, I changed the code to this:

const kelvin = 294;
const Celcius = Kelvin - 273;
let fahrenheit = Celcius * (9/5) + 32;
fahrenheit = Math.floor(fahrenheit);
console.log("The temperature is ${fahrenheit}  degrees fahrenheit");

and I get this error now: “ReferenceError: Kelvin is not defined”

(The prompt expression change worked, thank you <3)


variable names are case sensitive.


Guys, I fixed it: change kelvin to Kelvin (capital K) in all codes

I have another problem though: when replaced value of Kelvin with “prompt(‘What is the Kelvin temperature today?’);” the output shows this: “The temperature is ${Fahrenheit} degrees Fahrenheit”

my code for the string interpolation is as follows:
console.log(“The temperature is ${Fahrenheit} degrees Fahrenheit”);


Thank you! Just figured it out as well :smiley:


es6 string interpolation requires the string to be enwrapped in back-ticks, not apostrophes


ok need to befriend back-ticks. Thanks again!


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.