I am confused about how to generate a random number to either add or subtract 1 from the initial number.

Think about generating two numbers, perhaps 0 and 1. Then associate add 1 to one of the two options and subtract 1 to the other using an if....else.

You can also take the random number that's 0 or 1, and multiply it by 2, and then subtract one from that, to get either -1 or 1.