there are two small screws on the rear of the derailleur: these adjust the inner and outer limits of how far the derailleur can move. if you shift all the way to the biggest or smallest cog you should be able to observe them do their magic as you turn them, and you can adjust them so that the derailleur limits line up with those two cogs. second is cable tension: if, when you're shifting, the chain is slow/hesitant to go to a larger gear, that means you lack cable tension and you need to adjust one of the barrel adjusters (either on the derailler, or sometimes incorporated into the shifter or the frame) by LOOSENING it. if, when you're shifting, the chain is slow/hesitant to go to a smaller gear, that means your cable is too tight -- do the opposite -- tighten any barrel adjusters for that cable. best to go in small increments (1/2 turns or so). if none of that works you might need new cable and/or cable housing, and/or your derailleur hanger is bent... etc. also everything above applies to the rear derailleur. the front works in similar fashion but is more of a pain to adjust (the same principles apply).
if your chain is actually slipping over the teeth, that's a different issue, and means your drivetrain components are worn out. if your chainring (cogs attached to the crank) teeth are "sharp" or pointy rather than squared off, that would be an indication of a severely worn drivetrain where the chain could start slipping. then you need to start replacing parts including the chain, chainrings, rear cassette, and so forth.