Help finding this function?

The idea of this "proof" is very easy to understand.

Let f:[0,1]-->[0,1] be a continuous function. So you have a square one unit across and one unit tall. Draw a function inside of this box so that if you draw a horizontal line through the function anywhere, it will pass through the function 0 times or an even number of times (not infinitely many times).

Remember, the function has to be continuous on [0,1].

I thought for a while that this function doesn't exist, but my professor today confirmed it DOES exist. Has anyone ever heard of a theorem like this, and/or does anyone know a function that satisfies the criteria?