B is a function; A isn't
Work Step by Step
Let's look at the function A first( in black). We immediately see that there is x axis symmetry and that we can draw a vertical line at any line $x=c$ where c is an arbitrary natural number. Thus it fails the vertical line test and isn't a function! Next we look at B which is pink. From what we see, it looks like simple harmonic motion or a sinusoidal curve. This kind of graph is a function since we cannot draw a vertical line ANYWHERE through 2 or more points. Thus it is a function.