Although, I feel that I do get the concept of it, I still have a hard time understanding some of evolution.

I get that animals pass down genes to their offspring that best suit their envioronment while the genes that don't fit, eventually get weeded out.

For example, tell me if I'm wrong, according to natural selection, if a group of giraffes move to a place where there are tall trees, the taller giraffes have an advantage because they can reach the leaves and eat. They then mate and get it on and produce offspring with genes that determine their height (taller in this case). Whereas shorter giraffes die from not being able to reach the leaves, and since they are dead, they cannot produce offspring. The shorter gene is eventually weeded out over a series of generations and taller giraffes getting it on.

What I have a hard time understanding is how do animals produce new genes? Where did the gene come from that makes polar bears white instead of black/brown? Why are certain peppers hotter than others?

Note: I did not make this thread to debate. So if you have anything to say that goes against the idea of this thread, which is for me and others reading to learn, please leave and not turn this into a mess.