One important factor to consider when buying a DSLR is ergonomics. Tell your friend to try each camera out in his/her hands, navigate the camera's menus, and see which one feels better snapping photos and controlling the settings with.
It's also important to think about what lenses he'll/she'll use the most. Canon seems to have a bit of a better selection of telephoto lenses, so if your friend will be shooting sports, action or wildlife the 40D may be a better choice. However, Nikon has an excellent selection of wide angle lenses (plus, the Nikon has a slightly higher resolution), so the D90 may be a bit of a better choice for landscapes.
If I had to choose, I'd go with the D90, as it's newer, shoots video and has better image quality. However, if your friend prefers the ergonomics of the 40D it should be his/her choice.
Another option to consider is buying a brand new entry level camera, such as Nikon's D5100 or Canon's 600D (or the 550D to save some cash). Generally, they'll offer the same IQ (Image Quality) as the higher end camera like the 60D or D7000, but you're paying a lower price because they leave out features like a magnesium alloy body, a top LCD display, dedicated control buttons and generally have a smaller, dimmer viewfinder. If at the end of the day all that your friend really cares about is the IQ of his/her final photos, I'd definitely consider an entry level body. Also remember that if you buy a new body as opposed to a second hand body, you're guaranteed that the camera hasn't been dropped or abused, plus you get a warranty in case you get a lemon.
By the way, is video something that matters to your friend? If so, definitely go for Canon, something like the 600D would be perfect.
Hope that I helped,
Gear: 7 Nikon Nikkor AI-S and AF-S lenses, SB-700 flash, Nikon D7000, Nikon FM, variety of accessories
"There are no rules for good photographs, there are only good photographs."
- Ansel Adams