I'm randomly generating numbers inside of an array.

Here's my code:

Code JavaScript:
var max = 10,
    lowest = 1,
    store = [];
while(store.length < max) {
    var values = Math.floor(Math.random() * max) + 1;
    if(store.indexOf(values) === -1) {

The code works perfectly fine, but when I move the values variable outside of the while-loop and declare it above the while loop scope, it causes an infinite loop. Is this because the while-loop needs the values variable to keep repeating itself in it's scope?