Skip to content
Sign upLog in
← Back to Community

"variable" is declared, but the value is never read issue

Profile icon
TieDyeKatz

In my code, I defined the variable unit as a readline prompt, but it is only reading it as f instead of f, c, or k. My if statement is not helping here, as it is only going to act like I pressed f. Can you please help me?

I am using NodeJS, and Here is my code.

Answered by ArchieMaclean [earned 5 cycles]
View Answer
Voters
Profile icon
TieDyeKatz
Comments
hotnewtop
Profile icon
ArchieMaclean

When comparing 2 items, you need to use == instead of just =. So line 3 should read:

if (unit=="f") {

Before, you were doing one = which just sets unit to "f".
You need to sort this on lines 3, 10 and 17.

Please mark this as the answer if it solved your problem :)