this.form = document.getElementById('quiz');
this.cards = Object.entries(pairs).flat()
.map(e => e.toString())
- .sort(() => {return .5 - Math.random()}) // shuffle
+ .shuffle()
this.cards.forEach(word => {
put(this.form,
'figure>img[src=$]<', `/data/word/en/${word}.jpg`,
'+img[src=$]+ul', `/data/word/en/${word[0]}.jpg`,
);
- let answers = [word[2], this.words[1][2], this.words[2][2], this.words[3][2]]
- .sort(() => {return .5 - Math.random()}) // shuffle
+ let answers = [word[2], this.words[0][2], this.words[1][2], this.words[2][2]]
+ .shuffle()
answers.forEach(suggest => {
let label = suggest.replace(/\/.*/, '');
let option = put(form, 'li', label, {onclick: () => {
+Array.prototype.shuffle = function () {
+ return this.sort(() => {return .5 - Math.random()});
+};
+
class WordQuiz {
dataselect(json) {
let rows = Object.values(json);
- return rows.sort(() => {return .5 - Math.random()}) // shuffle
+ return rows.shuffle();
}
load(dataurl) {