0

So I am trying to make a small program with which I could study vocab terms. I have all the the terms and definitions as

var term1 = "foo";
var definition1 = "bar";
var term2 = "foo2";
var definition2 = "bar2";

et cetera. I have a function nextCard() that increments a variable cardNum and one previousCard() that decrements it. They both then call another function updateCard() that updates the term/definition showing. It is possible to write a line that says

if (cardSide === 0) {
    document.getElementById("card").innerHTML = term[cardNum] // this doesn't actually work, but that is what I want the output to be
} else {
    document.getElementById("card").innerHTML = definition[cardNum] // again, same thing
}

I've looked and can't find anything online. Please help.

0 Answers0