Kelvin weather


Hello i tried to run this and i got the next message:

SyntaxError: Unexpected identifier ‘fahrenheit’

Here is my code, can someone help to me find the mistake, please?

const kelvin = 294; // We will not change the value saved to kelvin.
const celsius = kelvin - 273; // Celsius is similar to Kelvin, the only difference is that Celsius is 273 degrees less than Kelvin.
let fahrenheit = celsius * (9/5) + 32; // Change Celcius to fahrenheit.
fahrenheit = Math.floor(fahrenheit); // Will round the number.
console.log(`The temperature is ${fahrenheit} degrees fahrenheit.`); // String interpoilation to log the temperature in fahrenheit.
const kelvin = prompt('What is the Kelvin temperature today?'); // Generates a pop-up window that asks the user for input, then it will assign their input to a variable.


The last line is meant to replace the first line, in the last step.


Ok i put it like this:

const kelvin = prompt('What is the Kelvin temperature today?'); 
const celsius = kelvin - 273; 
let fahrenheit = celsius * (9/5) + 32; 
fahrenheit = Math.floor(fahrenheit); 
console.log(`The temperature is ${fahrenheit} degrees fahrenheit.`); 

And yet got the same syntax error, is there something wrong?


What does the error message say? (Also, please include a link to the exercise.)


Unexpected identifier ‘fahrenheit’


Try a page refresh then run again.


Ok, and maybe run the program step by step could help, right?


Your code looks fine. It could just be artefacts still in memory. A Refresh will start a new session but will keep your code.


I got it like this and runs perfect:

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

I used only const for variables, while before i was using let for fahrenheit, what could that mean?


It shouldn’t matter. You’re in global scope so technically let should work for all of three. Write what is asked for in the instructions.


That’s what i did, and then i used the hints and even tho it didn’t worked, so i decided to try const instead of let for that sentence, and it just ran perfectly


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