jeudi 9 mars 2017

is there a way to get info from a variable that is defined inside a function?

I am trying to figure out if there is a way to access the information stored inside a variable that I defined inside a function? I am kinda confused on how to do what I am trying to do here...

note: this isn't the full code, but the piece of the code I need help with.

let question1 = new Question("What is California State Flower?", "1. Rose. 2. Tulip. 3. Poppy");
firstQuestion();


function firstQuestion(){
  let someAnswer = prompt(question1.questionName + " " + question1.questionString);
}

if (someAnswer == "poppy"){

I am trying to use the if statement to figure out if a question answer is correct, but I can't do that because someAnswer was defined inside the function.... and i'm not sure if there is a way to do this without using a function?

Aucun commentaire:

Enregistrer un commentaire