-class WordMemory {
+class WordMemory extends WordQuiz {
turn(click) {
let target = click.currentTarget;
if (!target.classList.contains('turn')) {
.forEach(card => put(card, '!.turn!.bad'));
}
- constructor() {
+ load(dataurl) {
this.dataurl = '/data/wordpairs.json';
fetch(this.dataurl).then(res => res.json()).then(pairs => {
this.turned = [];
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`,
});
}
};
-
-new WordMemory();