猿问

js中一个字符串数组,怎么随机取出;

例如:

var c=[c1,c2,c3,c4,c5,c6,c7,c8,c9]

var d=[d1,d2,d3,d4,d5,d6,d7,d8,d9]

这一数组,怎么用随机数随机分别取出其中能够的值,而且数据类型不变。

这样写可以吗?

var Cran=Math.floor(Math.random()*c.length)

console.log(Cran);

console.log(c[Cran]);

console.log(c[Cran].style.display="display");

 



Dummy
浏览 3408回答 0
0回答

慕瓜9220888

ZNPRGZMSPRIMHZCSVYUBNPRHDFBKRGSQATMZOFQZXQVBOGRJRWGSXQRLNSEHNCVYJBWODMZZJBYZIHKADUOTFHGDVYCMFDZCYVEIZHCEHHXQFTEXFIRBKOZUJVUEAUCTLALOOOALMCRTZWIPPQYXIQDGGQKTBTAYLNFGVXFYQDDKVKCURRPZPHMNGGCSYVJOTIVVBLKXPNZIVYHRPAFRWSPYHINFBHCLBKLXFEFVOYUMXWMJFICPGIASILBHDEDOTWWPFALNSEXNMDXOQLWWDCTXGPNFPSLILKCLTCCVCYJFHCADQATLTYTDWLOPKIAZISQZEFQPAANNTBFEWLXHGDEXMECPLYUYFQXPCLIIYJBTIOGQGLCOQVIORDYMRTWZJMLLPUZLERKNNEPYJCCVYPDMUQZMFZTBASVLIBONYNNFOORKIZLDYBEHRPGLEPISBLYPNWEUXKJYQSDSLEOHHYDVHQAAAZCUCKKXNJPKDSKNUQJXFDVNNIBBRCXSBKHGKHLDPEADXQNPSUNOELPNCLXFIYBYDEGFDQDDWTOJEDGJJFHUCRJMYOVOIUJBUEUFOGHQLYBRZMXMXMJICYZUJUDMTVFHIAPISIYFZAJUZMFVCPIQVAKQJPPQIXJCEQAQHZOAGJMXUVTVKXAATZKPAJPIYVJQFXPFVFJMXMOWWFAAJGOGPSSBOEZOJFVEENJLTCIISDVWNCHWZSLBFNCDVPOERXOAKFLYHRULXJMDWCSDEZODIRYHEIKSUKWMJXFHZOUUXQRPEWOYHNKOVASXHDQTVMSQFIBOBHXMFHYFVMJHZHJSCVDCKJKTJPATHBNC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