It's quite easy, actually.
Like in English, when you have "An" and "A", you just perform a vocal check to test whether it sounds right or not.
Same in Danish, but with a slight twist, since "Et" and "En" can also appear on the end of a word to make it a "The".
You simply put it at the end of the word and perform a vocal check on whether it sounds right.
Æble - try using both at the end, notice how "et" sounds right and "en" sounds silly?
Frugt - Try it, now "en" sounds right and "et" sounds silly.
By time, you'll have the formula in your head and it'll all seem easy.
Har en god dag!