6. Asking for feedback - typeError: console.log is not a function


#1

Help,

I'm getting this error message on and on - I tried copying and pasting correct codes from forum and nothing works, I still get the "TypeError: console.log is not a function."
My code:
console.log("You are at a Justin Bieber concert, and you hear this lyric 'Lace my shoes off, start racing.'");

console.log("Suddenly, Bieber stops and says, 'Who wants to race me?'");

var userAnswer= prompt("Do you want to race Bieber on stage?");

confirm ('Are you ready to play?');// Check if the user is ready to play!

var age= prompt("What's your age");

if(age<13) {
console.log("You are allowed to play but we take no responsibility");
}
else {
console.log("Play on!");
}

if(userAnswer="yes") {
console.log=("You and Bieber start racing. It's neck and neck! You win by a shoelace!");
}
else {
console.log("Oh no! Bieber shakes his head and sings 'I set a pace, so I can race without pacing.'");
}

var feedback = prompt ("what is your rating out of 10?");
if(feedback>8)
{
console.log("Thank you! We should race at the next concert!");
}
else
{
console.log("I'll keep practicing coding and racing.");
}


#2

Console.log is not a function

The right code is

  1. prompt(userAnswer="Do you want to race Bieber on stage?")
    Your anwser was:
  2. var age= prompt("What's your age");
    Whitch its saying its not like a function since you assigned it to a variable.

Hope that works if you want code:

confirm("Are you ready to play?");
var age = prompt("How old are you?");
if (18<(age)) {
console.log("You're old enough to play");
} else {
console.log("You're NOT old enough to play");
}
console.log("You are at a Justin Bieber concert, and you hear this lyric 'Lace my shoes off, start racing.'");
console.log("Suddenly, Bieber stops and says, 'Who wants to race me?'");
prompt(userAnswer="Do you want to race Bieber on stage?");
if(userAnwser="yes")
{console.log("You and Bieber start racing. It's neck and neck! You win by a shoelace!")}
else
console.log("Oh no! Bieber shakes his head and sings 'I set a pace, so I can race without pacing.'");
var feedback= prompt("How did you like this") ;
if(userAnwser>8)
console.log("Thank you! We should race at the next concert!");
else
console.log("I'll keep practicing coding and racing.");

#4

Normally console.log is not a function refers to the use of console.log = (...) where console.log got overwritten by a new value. In any case to fix this just refresh the page and try again. Sounds stupid, but this resets console.log to it's default value.

@amanuel2
What do you mean by this?

prompt(userAnswer="Do you want to race Bieber on stage?")
Your anwser was:var age= prompt("What's your age");
Whitch its saying its not like a function since you assigned it to a variable.

Also use a comparison operator here:

if(userAnwser="yes")

#5

Hi, thank you for your answer, refreshing the page doesn't fix it as well - tried couple of times, then I logged off, tried the next day, nothing works... I think I will just skip that lesson...


#6
if(userAnswer="yes") {
    console.log=("You and Bieber start racing. It's neck and neck! You win by a shoelace!");

have you fixed this before refreshing?
Add a = after userAnswer to compare instaed of assign and remove the = between console.log and (...).


#7

Sorry i wasnt on. Are you still facing the problem?


#8

This is my code:

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

console.log("Suddenly, Bieber stops and says, 'Who wants to race me?'");

var userAnswer= prompt("Do you want to race Bieber on stage?");

confirm ('Are you ready to play?');// Check if the user is ready to play!

var age= prompt("What's your age");

if(age<13) {
console.log("You are allowed to play but we take no responsibility");
}
else {
console.log("Play on!");
}

if(userAnswer="yes") {
console.log=("You and Bieber start racing. It's neck and neck! You win by a shoelace!");
}
else {
console.log("Oh no! Bieber shakes his head and sings 'I set a pace, so I can race without pacing.'");
}

var feedback = prompt ("what is your rating out of 10?");
if(feedback>8)
{
console.log("Thank you! We should race at the next concert!");
}
else
{
console.log("I'll keep practicing coding and racing.");
}

It seemed correct from the start but I also tried copying and pasting other people's codes - still the same thing.
@amanuel2 I still have that problem.


#9

This is certaintly a Bug

Noticed the problem was on the feedback userinput. I litterarly took the prompt from age and copied it and changed that prompt to feedback but it still didnt work. This is definitely a :bug: .


#10

As said your problem are these lines:

if(userAnswer="yes") {
console.log=("You and Bieber start racing. It's neck and neck! You win by a shoelace!");

first fix them, then refresh the page and then run it again.


#11

As usual i am wrong :frowning: i didnt know where the problem was :frowning: