|
@@ -40,6 +40,27 @@ export class FlashCardsProvider {
|
40
|
40
|
allCards() {
|
41
|
41
|
return this.defaultCards
|
42
|
42
|
}
|
|
43
|
+ shuffle(array) {
|
|
44
|
+ var currentIndex = array.length, temporaryValue, randomIndex;
|
|
45
|
+
|
|
46
|
+ // While there remain elements to shuffle...
|
|
47
|
+ while (0 !== currentIndex) {
|
|
48
|
+
|
|
49
|
+ // Pick a remaining element...
|
|
50
|
+ randomIndex = Math.floor(Math.random() * currentIndex);
|
|
51
|
+ currentIndex -= 1;
|
|
52
|
+
|
|
53
|
+ // And swap it with the current element.
|
|
54
|
+ temporaryValue = array[currentIndex];
|
|
55
|
+ array[currentIndex] = array[randomIndex];
|
|
56
|
+ array[randomIndex] = temporaryValue;
|
|
57
|
+ }
|
|
58
|
+
|
|
59
|
+ return array;
|
|
60
|
+ }
|
|
61
|
+ randomCards() {
|
|
62
|
+ return this.shuffle(this.defaultCards)
|
|
63
|
+ }
|
43
|
64
|
|
44
|
65
|
testCards =
|
45
|
66
|
[
|