According to the bible, Jesus went on a 40 day fast in the desert (don't know why) and he was tempted by the devil, but he didn't give in.
Christians and some other religions give something up that you like, like chocolate, or alcohol for 40 days to symbolise that.
I'm nt really christian but I do it anyway, just because.
