I am making a rock paper scissors game as part of learning JS and I ran into a function that is quite different from mine:
const myArray = ["Rock", "Paper", "Scissors"];
function computerPlay() {
return myArray[~~(Math.random() * myArray.length)];
}
My function did not use an array, but math.floor/random'd numbers that were then assigned values. So I'm curious... what is the double tilde? I read up on it a little bit but I know I don't fully understand the implications of a double tilde vs. .floor (or any other uses beyond it executing performing the same end faster).
So, what exactly does double tilde do in it's myriad of uses?