My first answer would be that it depends and so learning by heart and reading & listening in french makes you learn slowly if the noun is feminine or masculine. Also visually remembering the nouns ending with an -e can help as most of them are then feminine, but there are many exceptions "un arbre", " un portable" etc. So my best tip is to think of the family of the noun, and try to find another word from the same family. Usually that word is going to have the same gender as the noun you were trying to figure out . ex: un cheval, un chevalier etc.