-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfavorites.js
39 lines (33 loc) · 2.97 KB
/
favorites.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
const FAVORITES = [
"eyJjZW50ZXIiOlt7ImJpZ0ludCI6Ii01MTAzNTk3MzI2OTY5OTY3NzAiLCJzY2FsZSI6NTh9LHsiYmlnSW50IjoiLTQ3MDc1NTI5NjU0NDU3NDQiLCJzY2FsZSI6NTh9XSwiem9vbSI6eyJiaWdJbnQiOiIxODA0MjE1MzE1Nzc4Mjk4Mzc4MzU0NTA5OTQ0NTEzIiwic2NhbGUiOjU4fSwibWF4X2l0ZXIiOjM0MDAsInNtb290aCI6dHJ1ZSwicGFsZXR0ZSI6eyJpZCI6Im9yaWdpbmFsIiwiZGVuc2l0eSI6Ii0yMiIsInJvdGF0ZSI6Ii0xODAifX0=",
"eyJjZW50ZXIiOlt7ImJpZ0ludCI6Ijg5NjExNDQxMDMxODc0ODYzNTE2OTA1NiIsInNjYWxlIjo4MX0seyJiaWdJbnQiOiItMTYyMDk5NjI0MTIxNzA3MTY5OTYxOTg3MiIsInNjYWxlIjo4MX1dLCJ6b29tIjp7ImJpZ0ludCI6IjI5NDU5ODIyMjI3ODcyNzE0MjUwNzgwMTU3NzA4MDc1MDg1MzA2NDI2MDk3NiIsInNjYWxlIjo4MX0sIm1heF9pdGVyIjoxMDAwLCJzbW9vdGgiOnRydWUsInBhbGV0dGUiOnsiaWQiOiJqZXdlbGxlcnkiLCJkZW5zaXR5IjoxLCJyb3RhdGUiOjB9fQ==",
"eyJjZW50ZXIiOlt7ImJpZ0ludCI6IjQwNzc5NjA3MjAzMjk2Nzc5NzA3OTYyMjgwNDg1MjQiLCJzY2FsZSI6MTAzfSx7ImJpZ0ludCI6Ii02MTM0NjM1NzEwNzU2MTcyNDEzODM0NzY5NTEzNDkyIiwic2NhbGUiOjEwM31dLCJ6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IjoiLTMyNzk2NjU0MTc3NDY2OTcxNjYzMjUiLCJzY2FsZSI6NzN9XSwiem9vbSI6eyJiaWdJbnQiOiI2MTQ1MTM5NDMwOTAzNDkxNjA0NDU2MjcwMjM4MTUzNzYzNjgzMjY2Iiwic2NhbGUiOjczfSwibWF4X2l0ZXIiOjEyMDAsInNtb290aCI6dHJ1ZSwicGFsZXR0ZSI6eyJpZCI6ImxhdmEiLCJkZW5zaXR5IjoxLCJyb3RhdGUiOiItNCJ9fQ==",
]
const luckyOrder = []
export function getRandomFavorite() {
if (luckyOrder.length === 0) {
for (let i = 0; i < FAVORITES.length; i++) {
luckyOrder.push(i)
}
shuffle(luckyOrder)
}
const favoriteIndex = luckyOrder.pop()
console.log(`favorite ${favoriteIndex}`)
return FAVORITES[favoriteIndex]
}
function shuffle(array) {
let currentIndex = array.length, randomIndex;
// While there remain elements to shuffle.
while (currentIndex > 0) {
// Pick a remaining element.
randomIndex = Math.floor(Math.random() * currentIndex);
currentIndex--;
// And swap it with the current element.
[array[currentIndex], array[randomIndex]] = [
array[randomIndex], array[currentIndex]];
}
return array;
}