Woo first stackover flow post!
I'm trying to change a result depending on what "character" button is clicked.
So I start with a variable called: gendr = [];
.
if the button named "marge" is clicked, the margeFunction will run, which pushes the value "female" inside the array. If the button "Henry" is clicked, the henryFunction will run, which pushes the value "male" inside the array.
A later function contains an if else statement, where if the array contains the value male "male sentence appears." else if the arrays value is female, "female sentence appears."
function helloFunction() {
if(gendr[female]) {
document.getElementById ('traitText').innerHTML = "and says the word hello in every sentence she speaks";
} else {
document.getElementById ('traitText').innerHTML = "and says the world hello in every sentence he speaks"
}
}
I'm not exactly sure how to do this I just made a guess but I would like to know the correct way to do this! thanks in advance :)