I cant figure out what is wrong with my code?!


#1

var answer = prompt("What is your favouraite game?");

switch(answer) {
case'Subway Surfers':
console.log(" I love" + answer);
break;
case ' Vector'
console.log( answer+"is awesome")
break;
default:
console.log("I dont think I like" + answer);

}


#2

Hey @pyace49526! Its just a tiny mistake after your case you missed your Colon ( : ) I will comment the part you missed in the code:

switch (answer) {
    case 'Subway Surfers':
        console.log(" I love" + answer);
        break;
    case ' Vector' <<-- Here you forgot to put a colon ( : )
    console.log(answer + "is awesome")
    break;
    default:
        console.log("I dont think I like" + answer);

}

#4

var answer = prompt("What is your favouraite game?");

switch(answer) {
case'Subway Surfers':
console.log(" I love" + answer);
break;
case ' Vector':
console.log( answer+"is awesome")
break;
default:
console.log("I dont think I like" + answer);

}

@amanuel2 this still dosent work it just gives me an error message saying "TypeError: Object doesn't support property or method 'log'"


#5

Yea you forgot to declare a variable named anwser, with the user prompt. So you forgot this piece of code:

var answer = prompt('Whats your favorite game')

You didnt declare a variabe, so it wont know what anwser meant, so you need to define it first then you can use it in your code.


#6

I did declare it...look at my first post @amanuel2


#7

What exercice is this?


#8

its the 7th one in More on Control Flow in JS on javascript


#9

What do you use to browse? Safari,Chrome,Ie,Opera??...


#10

its Microsoft edge on my windows 10 laptop @amanuel2


#11

Thats why, try it with google-chrome.


#12

I just refreshed my browser for the 4th time and it works ... on Microsoft edge and chrome as well


#13

thank you very much tho


#14

No Problem! Have fun learning!

Intrested in Web Develpoment? Want to know more? Where to go next?This is the place for you!

Instrested in Game Development?Want to know more? Where to go next? This is the place for you!