Note that there are some explanatory texts on larger screens.

plurals
  1. POrandomize javascript array keeping key value pairs
    primarykey
    data
    text
    <p>I'm trying to randomize an array in JavaScript whilst keeping key/value pairs. Here's what I've got so far:</p> <pre><code>data=[ ["images/staff/img_staff_akwok_s.gif","Dr. A. Kwok","staff_akwok.phtml"], ["images/staff/img_staff_ayiu_s.gif","A. Yiu","staff_ayiu.phtml"], ["images/staff/img_staff_ally_s.gif","Ally Lee","staff_ally.phtml"], ["images/staff/img_staff_calvinkwan_s.gif","Calvin Kwan","staff_calvinkwan.phtml"], ["images/staff/img_staff_charles_s.gif","Charles Carlyle","staff_charles.phtml"], ["images/staff/img_staff_cherlotte_s.gif","Cherlotte","staff_cherlotte.phtml"], ["images/staff/img_staff_cychau_s.gif","C.Y. Chau","staff_cychau.phtml"], ["images/staff/img_staff_cyrus_s.gif","Cyrus","staff_cyrus.phtml"], ["images/staff/img_staff_cyruxleung_s.gif","梁詩穎","staff_cyruxleung.phtml"], ["images/staff/img_staff_davidchiu_s.gif","David Chiu","staff_davidchiu.phtml"], ["images/staff/img_staff_davidho_s.gif","David Ho","staff_davidho.phtml"], ["images/staff/img_staff_frankietam_s.gif","Frankie Tam","staff_frankietam.phtml"], ["images/staff/img_staff_jeremy_s.gif","Jeremy","staff_jeremy.phtml"], ["images/staff/img_staff_jng_s.gif","J.Ng","staff_jng.phtml"], ["images/staff/img_staff_jo_s.gif","Jo","staff_jo.phtml"], ["images/staff/img_staff_joesuen_s.gif","Joe Suen","staff_joesuen.phtml"], ["images/staff/img_staff_johnny_s.gif","張烈","staff_johnny.phtml"], ["images/staff/img_staff_jt_s.gif","J.T.","staff_jt.phtml"], ["images/staff/img_staff_jyeung_s.gif","J. Yeung","staff_jyeung.phtml"], ["images/staff/img_staff_kam_s.gif","曾定金","staff_kam.phtml"], ["images/staff/img_staff_kit_s.gif","黃政傑","staff_kit.phtml"], ["images/staff/img_staff_marcochan_s.gif","Marco Chan","staff_marcochan.phtml"], ["images/staff/img_staff_oten_s.gif","K.OTen","staff_oten.phtml"], ["images/staff/img_staff_leungsir_s.gif","梁頌佳","staff_leungsir.phtml"], ["images/staff/img_staff_lun_s.gif","李聚麐","staff_lun.phtml"], ["images/staff/img_staff_peterchow_s.gif","Peter Chow","staff_peterchow.phtml"], ["images/staff/img_staff_raphael_s.gif","Raphael","staff_raphael.phtml"], ["images/staff/img_staff_raymondwong_s.gif","Raymond Wong","staff_raymondwong.phtml"], ["images/staff/img_staff_rickyuen_s.gif","Rick","staff_rickyuen.phtml"], ["images/staff/img_staff_river_s.gif","余江河","staff_river.phtml"], ["images/staff/img_staff_samuelyu_s.gif","Samuel Yu","staff_samuelyu.phtml"], ["images/staff/img_staff_shun_s.gif","楊家舜","staff_shun.phtml"], ["images/staff/img_staff_stefanie_s.gif","Stefanie Chan","staff_stefanie.phtml"], ["images/staff/img_staff_thomas_s.gif","Thomas Yan","staff_thomas.phtml"], ["images/staff/img_staff_tonyyoon_s.gif","Tony Yoon","staff_tonyyoon.phtml"], ["images/staff/img_staff_victoria_s.gif","Victoria Poon","staff_victoria.phtml"], ["images/staff/img_staff_wchen_s.gif","陳偉亮 (W.Chen)","staff_wchen.phtml"] ] data = data[Math.floor(Math.random()*data.length)] </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload