I would like to shuffle the answers of each question of a quiz
[{"answers 1":"9 s 58","answer2":"9 s 72","answer3":"8 s 42","answer4":"8 s 36"},{"answer1":"Ottawa","answer2":"Toronto","answer3":"Montréal","answer4":"Québec"},{"answer1":"Mathilde","answer2":"Elizabeth","answer3":"Fabiola","answer4":"Paola"}]
I use the shuffle method of lodash
import shuffle from 'lodash/shuffle';
export default {
mounted() {
this.$axios
.get("http://localhost:4000/api/answers/" + this.$route.params.idQuiz)
.then((response) => {
this.reponses = response.data;
for (var question in this.reponses){
shuffle(this.reponses[question])
}
console.log(this.reponses);
})
.catch((error) => {
console.log(error);
}),
Aucun commentaire:
Enregistrer un commentaire