Javascript Code your own Adventure Problems


#1

Javascript 1.2


Keeps telling me that console.log is not a function.


confirm("Are you ready to play?");
var age = prompt("What is your age?");

if (age < 13)
 {   console.log = ("You're allowed to play but take no responsibility");

} else (age > 13); {
 console.log = ("Have fun playing!");
} 

console.log("You are at a Justin Bieber concert, and you hear this lyric 'Lace my shoes off, start racing.'");

I cant figure out what is wrong with this code. Someone please help! It keeps telling me console.log is not a function in the error box.


#2

Console.log is run like this:

console.log("String");

You're trying to use it like it's a variable. Just get rid of the equal (=) signs and the spaces, and you'll be good to go.


#3

I removed all spaces, I am still getting the same error I was before.


#4

Like @toplearner said you also have to get rid of the equal signs (=) .

After you have done that your code should look like this:

confirm("I am ready to play!");
var age = prompt("What's your age"); 
if(age < 13){

    console.log("You are allowed to play but you take no responsibility") }
   
 else {
        console.log("Play On!") }
        
console.log("You are at a Justin Bieber concert, and you hear this lyric 'Lace my shoes off, start racing.'");

And there is also no need to put any parenthasis () after your else. Because when you use else it automatically means anything over 13.


#5

Thank you for your help! I got it running and realized what I was doing wrong before! Much appreciated!!


#6

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