Texas Instruments Interview Question

How does a transistor work as a switch?