1. okay there is my code i just want to how wouldi add a score counter to it. Right now my code is doing this, the function question call is calling the main function which generates a number and if the number matches the condtion it goes and displays the given function. Howver, what i want to do is when it goes and gets the givin function , if the answer is right i want to add 1 to the varible and if its wrong i want to minus one. How can this be done, and is the code so far correct?

var num = 3
var y = 0

for(1=1;i<15;i++){
var x = math.floor(math.random()*num)+1
while (x==y){
var x = math.floor(math.random()*num+1
}
}
}

function question_call(){
main()
if(x == 1){
question1()
}else if(x == 2){
question2()
}else if(x == 3){
question3()
}else if(x == 4){
question4()
}else if(x == 5){
question5()
}else if(x == 6){
question6()
}else if(x == 7){
question7()
}else if(x == 8){
question8()
}else if(x == 9){
question9()
}else if(x == 10){
question10()
}else if(x == 11){
question11()
}else if(x == 12){
question12()
}else if(x == 13){
question13()
}else if(x == 14){
question14()
}else (x == 15){
question15()
}

2. ** REGISTER to REMOVE This Ad On The Site!! **
3. okay here is my updated code with what i think is the coutner , but the code doesnt seem to run. please help

Code:
```<script type="text/javascript">
var score = 0
question_call()
function main(){

var num = 15
var y = 0

for(1=1;i<15;i++){
var x = math.floor(math.random()*num)+1
while (x==y){
var x = math.floor(math.random()*num+1
}
}
}

function correct(){
score = score + 1;
}

function wrong(){
score = score - 1;
}

function question_call(){
main()
if(x == 1){
question1()
}else if(x == 2){
question2()
}else if(x == 3){
question3()
}else if(x == 4){
question4()
}else if(x == 5){
question5()
}else if(x == 6){
question6()
}else if(x == 7){
question7()
}else if(x == 8){
question8()
}else if(x == 9){
question9()
}else if(x == 10){
question10()
}else if(x == 11){
question11()
}else if(x == 12){
question12()
}else if(x == 13){
question13()
}else if(x == 14){
question14()
}else (x == 15){
question15()
}

function question1(){
var question_1 = prompt("Who Is The Villan In Star Wars?")
correct()
main()
}
else {
wrong()
main()
}

function question2(){
var question_1 = prompt("Who Is The second Villan In Star Wars ?")
if(question_1 == "Darth Maul"){
correct()
main()
}
else {
wrong()
main()
}

function question3(){
var question_1 = prompt("Who Is The4 Villan In Star Wars?")
correct()
main()
}
else {
wrong()
main()
}

function question4(){
var question_1 = prompt("Who Is The 4Villan In Star Wars?")
correct()
main()
}
else {
wrong()
main()
}

function question5(){
var question_1 = prompt("Who Is The Vi4llan In Star Wars?")
correct()
main()
}
else {
wrong()
main()
}

function question6(){
var question_1 = prompt("Who Is The Vi4llan In Star Wars?")
correct()
main()
}
else {
wrong()
main()
}

function question7(){
var question_1 = prompt("Who Is 4The Villan In Star Wars?")
correct()
main()
}
else {
wrong()
main()
}

function question8(){
var question_1 = prompt("Who Is The Villan In Star Wars?")
correct()
main()
}
else {
wrong()
main()
}

function question9(){
var question_1 = prompt("Who Is The Villan I4n Star Wars?")
correct()
main()
}
else {
wrong()
main()
}

function question10(){
var question_1 = prompt("Who Is The4 Villan In Star Wars?")
correct()
main()
}
else {
wrong()
main()
}

function question11(){
var question_1 = prompt("Who Is The Villan In Star Wars?")
correct()
main()
}
else {
wrong()
main()
}

function question12(){
var question_1 = prompt("Who Is The Villan In Star Wars?")
correct()
main()
}
else {
wrong()
main()
}

function question13(){
var question_1 = prompt("Who Is The Villan In Star Wars?")
correct()
main()
}
else {
wrong()
main()
}

function question14(){
var question_1 = prompt("Who Is The Villan In Star Wars?")
correct()
main()
}
else {
wrong()
main()
}

function question15(){
var question_1 = prompt("Who Is The Villan In Star Wars?")
correct()
main()
}
else {
wrong()
main()
}

</script>```

Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•