Need urgent help with a simple javascript code

hello i need to make a little program for school in javascript
its a simple respond program were u can put in how u feel from a scale from 1 to 10 and it will give a respone.
can someone please help me out with this since the code is not working
sorry if i made any stupid mistakes im quite new to this

heres the code:
var userChoice = prompt(“how are you feeling today on a scale from 1 to 10?”);
if (userChoice === 1) {
console.log (“that is terrible if hope your will beter soon!”);
}

if (userChoice === 2) {
console.log (“aww that sucks i hope you will have a nice day anyway!”);
}

if (userChoice === 3) {
console.log (“ooh thats not good! heres a smiley for you! :)”);
}

if (userChoice === 4) {
console.log (“it could be worse! keep haning in there!”);
}

if (userChoice === 5) {
console.log (“hmmm thomorow might be better, hang in there!”);
}

if (userChoice === 6) {
console.log (“most people feel the same your not alone!”);
}

if (userChoice === 7) {
console.log (“thats good! im feeling good today as well!”);
}

if (userChoice === 8) {
console.log (“great! keep up the good vibes!”);
}

if (userChoice === 9) {
console.log (“fantastic! it must be verry good weather or you just got free icecream!”);
}

if (userChoice === 10) {
console.log (“couldnt be greater! maby you could learn me a thing or to ;)”);
}

prompt stores the input as string, comparing strings with integers is very tricky. cast userChoice to a integer

i would use a switch statement in this case, but that is outside the scope of this question

3 Likes