Discuss Scratch
- Discussion Forums
- » Advanced Topics
- » Script not working
- RandomPerson1789
- Scratcher
100+ posts
Script not working
My script is not working (its html)
It is supposed to be a quiz game.
Here it is:
It is supposed to be a quiz game.
Here it is:
<html>Plz help
<head>
<script>
score = 0
alert(“Welcome to the quiz!”);
answer = prompt(“What is 1+1?”);
if answer==2 {
function cor();
} else {
alert(“Wrong!”);
}
answer = prompt(“What is 4X6?”);
if answer==24 {
function cor();
} else {
alert(“Wrong!”);
}
alert(“You got”, score, “out of 2 correct.”);
function cor() {
score = score + 1;
alert(“Correct!”);
}
</script>
</head>
</html>
- wkelly42
- Scratcher
100+ posts
Script not working
This is a forum for help with Scratch scripting ;-)
My Retro Arcade:
COMPLETED: Frogger, Missile Command, Computer Space.
IN DEVELOPMENT: Barnstorming, Time Pilot, Defender, River Raid, Karateka
- MegaApuTurkUltra
- Scratcher
1000+ posts
Script not working
This goes in advanced topics. Help with scripts is for Scratch script help.
$(".box-head")[0].textContent = "committing AT crimes since $whenever"
- djdolphin
- Scratcher
1000+ posts
Script not working
Try this:
You were using typographer's quotes (the curly ones) instead of straight ones, and you don't need to put “function” when you're calling a function - only when you're defining one. Also, use “+” to join strings, not commas.
<html> <head> <script> score = 0 alert("Welcome to the quiz!"); answer = prompt("What is 1+1?"); if (answer==2) { cor(); } else { alert("Wrong!"); } answer = prompt("What is 4X6?"); if (answer==24) { cor(); } else { alert("Wrong!"); } alert("You got " + score + " out of 2 correct."); function cor() { score = score + 1; alert("Correct!"); } </script> </head> </html>
!
- goldfish678
- Scratcher
1000+ posts
Script not working
<html> <head> <script> var score = 0 alert("Welcome to the quiz!"); answer = prompt("What is 1+1?"); if (answer==2) { cor(); } else { alert("Wrong!"); } answer = prompt("What is 4X6?"); if (answer==24) { cor(); } else { alert("Wrong!"); } alert("You got " + score + " out of 2 correct."); var cor = function() { score = score + 1; alert("Correct!"); } </script> </head> </html>
- MegaApuTurkUltra
- Scratcher
1000+ posts
Script not working
Improved a bit more. Also, I did report the OP to be moved to Advanced Topics a while ago. Where's the ST? sorry I can't read. I fell kind of stupid nowThis is djdolphin's, but improved.<html> <head> <script> var score = 0 alert("Welcome to the quiz!"); answer = prompt("What is 1+1?"); if (answer==2) { cor(); } else { nope(); } answer = prompt("What is 4X6?"); if (answer==24) { cor(); } else { nope(); } alert("You got " + score + " out of 2 correct."); var cor = function() { score++; alert("Correct!"); } var nope = function(){ alert("Wrong!"); } </script> </head> </html>
Last edited by MegaApuTurkUltra (Sept. 7, 2014 00:53:57)
$(".box-head")[0].textContent = "committing AT crimes since $whenever"
- RandomPerson1789
- Scratcher
100+ posts
Script not working
Thanks! Helped a lot Try this:You were using typographer's quotes (the curly ones) instead of straight ones, and you don't need to put “function” when you're calling a function - only when you're defining one. Also, use “+” to join strings, not commas.<html> <head> <script> score = 0 alert("Welcome to the quiz!"); answer = prompt("What is 1+1?"); if (answer==2) { cor(); } else { alert("Wrong!"); } answer = prompt("What is 4X6?"); if (answer==24) { cor(); } else { alert("Wrong!"); } alert("You got " + score + " out of 2 correct."); function cor() { score = score + 1; alert("Correct!"); } </script> </head> </html>
- Discussion Forums
- » Advanced Topics
- » Script not working