Reputation: 23
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>
Upvotes: 0
Views: 33
Reputation: 38
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")
}
Upvotes: 1
Reputation: 1218
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...
}
Upvotes: 0
Reputation: 4137
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>
Upvotes: 0