digital PB turn on output if pushed once and turn off if pushed again

How can I change this code so:

if fanOff is pushed the fan comes on and when pushed again the fan turns off?
No need to worry about switch bounce or time between pushes. Thanks for the help.

fanOff is a push button attached to a digital input.

if (pushed_fanOff) {//push button to shut down fan
    digitalWrite(fanRelay, LOW);//turn relay off
    digitalWrite(fanLed, LOW);

How can I change this code...

Look at the state change detection example. It shows how to tell if a switch has become pressed.

If it has, increment a counter.

Independently of checking the switch state, determine whether the number of presses is off or even (the modulo operator, %, is a candidate). If odd, do one thing. If even, do something else.