Texas Instruments interview question

How does a transistor work as a switch?