The loop will run until it find a spade, it might take 1 attempt, maybe a hundred, but it will find a spade, sooner or later. So at the end of the day, it will always tell you it found a spade
while loop is not a function, its a statement. So unless you use block scope variable (defined with let or const) the variable randomNumber will be global
if we defined var randomNumber in a function, then yes, the scope would have been local.