I am not seeing the issue here. I am new at JavaScript. I have researched variable scope and this looks correct to me. The issue is the variable, useAge, in the legalAge function is undefined. I have it declared before the function and passing it as a parameter to the function.
"use strict";
function person(){
alert("person function 1");
var personName = prompt("Enter a name:", "enter name here");
var personAge = parseInt(prompt("Enter " + personName + "'s current age:", "enter age here"));
var votingStatus = legalAge();
var statusMessage = (votingStatus == true) ? "old enough" : "not old enough";
document.writeln("<b>" + personName + " is " + personAge + " years old " + statusMessage + "</b><br />");
return personAge;
}
var useAge = person();
alert("useAge: " + useAge);
alert("outside function");
function legalAge(useAge) {
alert("legalVoting function 2");
var canVote = (useAge >= 18) ? true : false;
alert("Can Vote: " + canVote);
alert("age: " + useAge);
return canVote;
}
person();
var canVote = useAge >= 18;