Как - показване на случайно число измежду определени числа?

submit1

Registered
Здравейте,
намерих този скрипт http://jsfiddle.net/ZDsMa/433/
Въпросът ми е как да стане така, че аз да задам измежду кои числа да избира случайно, напр. да избере измежду 2349, 324, 8564, 98, 50
 
var randomNumber = Math.floor(Math.random() * 40) + 1;

1 - минамално
40 - брой възможни резултати, значи от 1 ,2,3,4..40

Код:
var output, started, duration, desired;

// Constants
duration = 5000;
desired = '5';

// Initial setup
output = $('#output');
started = new Date().getTime();

// Animate!
animationTimer = setInterval(function() {
    // If the value is what we want, stop animating
    // or if the duration has been exceeded, stop animating
    if (output.text().trim() === desired || new Date().getTime() - started > duration) {
        clearInterval(animationTimer);
    } else {
        console.log('animating');
        var randomNumber = Math.floor(Math.random() * 40) + 1;
        output.text(randomNumber);
    }
}, 100);
 
Благодаря за отговора!
Сетих се, че с масив ще стане.
Искам да попитам как да го активирам в html страница, например с клик на бутон от клавиатурата и да го спра пак с бутон от клавиатурата?

[js]var output, started, duration, desired;

// Constants
duration = 3000;
Numbers = [ 11,22,323,4433,345,116, 555];

// Initial setup
output = $('#output');
started = new Date().getTime();

// Animate!
animationTimer = setInterval(function() {
// If the value is what we want, stop animating
// or if the duration has been exceeded, stop animating
if (output.text().trim() === desired || new Date().getTime() - started > duration) {
clearInterval(animationTimer);
} else {
console.log('animating');
// Generate a random string to use for the next animation step
output.text(
''+
Numbers[ Math.floor( Math.random( ) * 6 ) ]
);
}
}, 100);[/js]
 

Back
Горе