Kelvin weather project - HELP


#1

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?


#2

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.


#3

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)


#4

variable names are case sensitive.


#5

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”);


#6

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


#7

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


#8

:woman_facepalming:
ok need to befriend back-ticks. Thanks again!


#9

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