Post

2 followers Follow
0
Avatar

TypeError:answer is null

const quiz= [
["Best state to live in?","Ca"],
["Capital of California","Jose"],
["Best beach","San"]
]

let score=0;

for(let i = 0;i<quiz.length;i++){
let answer = prompt(quiz[i][0]);
let answercorrect = answer.toString().toLowerCase().trim();//error is in this line

if( answercorrect === quiz[i][1]){
score++;

}
else{
alert('Wrong ans the correct answer is' + quiz[i][1]);
}
}

 

Amirush javare

Please sign in to leave a comment.