javascript - Remove the previous value and update the array -


having problem removing previous value array , updating remaining data.

for example, in code jsfiddle have 4 values in array: bmw, nissan, volvo , saab.

var cars = ["saab", "volvo", "bmw" , "nissan"]; shuffle(cars); document.getelementbyid("demo").innerhtml = cars[0]; 

so, once "press button" shows "bmw" or other value, next time reloading should randomize within rest of value i.e. nissan, volvo , saab.

var cars = ["saab", "volvo", **"bmw"** , "nissan"]; 

until ends , shows "no more value shown"

function shuffle(array) {   return array.splice(math.random() * array.length, 1).pop(); }  var cars = ["saab", "volvo", "bmw" , "nissan"]; var car = shuffle(cars); document.getelementbyid("demo").innerhtml = car; 

update

also note jsfiddle reloading whole js each time, ie. reloading initialization of cars each time, it's refreshing 4 initial values each time run it.


Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -