0

I know that this is basic JavaScript: when I open it in HTML it asks me the question but then doesn't follow through with the next line of code when I have answered the question. I don't now why this is and I would really appreciate some help.

<html>
<head>hi</head>
<script>if ( confirm("do you want to do the quiz") === true ) {
console.log("good")
}
else
{
console.log("ok")
 }
if ( prompt("What is the capital of france?") === "Paris" ) {
Console.log("that is right")
}
else
{
consle.log("unlucky")
}


</script>
</html>
5
  • 2
    You misspelled console twice. It's lower-case 'c'. Commented Jan 3, 2016 at 20:52
  • 1
    Also keep your browser developer tools open. You would have seen an error message. Commented Jan 3, 2016 at 20:53
  • Thanks for replying so quickly, really appreciate it. I'm coding in Notepad as part of html so no error message comes up. I corrected the typos but still the 'good', 'ok', and 'unlucky' still don't some up. I was wondering if adding a delay before the next command may help but I don't know how to do that. Would really appreciate some more help. Many thanks. Luke. Commented Jan 4, 2016 at 8:44
  • You have to run this in a web browser, and in order to see the output from console.log() you have to have the browser developer tools open. Commented Jan 4, 2016 at 14:28
  • Thanks working fine now. Luke Commented Jan 4, 2016 at 17:36

3 Answers 3

1

You misspelled console and also JavaScript is a case-sensitive language so console cannot be written as Console

try this

if ( confirm("do you want to do the quiz") === true ) {
console.log("good")
}
else
{
console.log("ok")
 }
if ( prompt("What is the capital of france?") === "Paris" ) {
console.log("that is right")
}
else
{
console.log("unlucky")
}

Sign up to request clarification or add additional context in comments.

2 Comments

I ran your code but it still doesn't say the 'good' bit or 'ok'. Would appreciate some more help. Thanks. Luke
Please use developer tools (google chrome press f12) and in developer tools open console.
0

Please try this , You have misspell console.log in two place

<html>
<head>hi</head>
<script>if ( confirm("do you want to do the quiz") === true ) {
console.log("good")
}
else
{
console.log("ok")
 }
if ( prompt("What is the capital of france?") === "Paris" ) {
console.log("that is right")
}
else
{
console.log("unlucky")
}


</script>
</html>

1 Comment

I really appreciate the quick reply but it still doesn't say 'good' 'ok' or 'unlucky'. Thanks. Luke.
0

I think you are asking user if he wants to play quiz, and if the user selects ok then you continue the quiz. For this you need to add all your quiz part in if block with console.log("good");

if(confirm("wanna play quiz?")){
   // start quiz
   if(prompt("question")=="answer"){
      console.log("That's right")
   }
   // more questions...
}

1 Comment

Thanks, really appreciate the quick reply but the line under the 'if' line doesn't come up it just moves straigght on to the nextquestion. Thanks. Luke

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.