let answers = [word[2], this.words[1][2], this.words[2][2], this.words[3][2]]
.sort(() => {return .5 - Math.random()}) // shuffle
answers.forEach(suggest => {
- let option = put(form, 'li', suggest, {onclick: () => {
+ let label = suggest.replace(/\/.*/, '');
+ let option = put(form, 'li', label, {onclick: () => {
if (suggest != word[2]) {
// incorrect
put(option, '.wrong');
});
}
- constructor() {
- this.dataurl = '/data/wordlist.nl.json';
- fetch(this.dataurl).then(res => res.json()).then(json => {
+ constructor(dataurl) {
+ fetch(dataurl).then(res => res.json()).then(json => {
this.form = document.getElementById('quiz');
this.words = Object.values(json)
.sort(() => {return .5 - Math.random()}) // shuffle
});
}
};
-
-new Quiz();