how can i make a random number that is either 1 or 2 [duplicate]

i’m making a very simple game and i wanted an input that could do two different things randomly. my first thought was to make a variable that switches between 1 and 2 randomly (or a boolean) but i don’t know how to make a random number yet. this all would drive a pair of if statements. i would also like to change it randomly either when player input happens or on a setInterval. i’m very new to html javascript, so try to be thorough with an explanation. thanks!

woops, i made the question rong. this is also my first question on this sight.