-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCompteurJetons.js
More file actions
34 lines (30 loc) · 836 Bytes
/
CompteurJetons.js
File metadata and controls
34 lines (30 loc) · 836 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
function CompteurJetons() {
var compte = 0;
var totalWords = 0;
var pourcent = 0;
/**
* Cette fonction retourne de jetons comptés
*/
this.getJetons = function () {
return compte * totalWords;
}
/**
* Cette fonction retourne le progès du compte, avec une valeur entre 0 et 100
*/
this.getProgress = function () {
return pourcent;
}
/**
* Cette fonction compte les jetons et retourne un objet de type Generator
* Voir documentation: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function*
*/
this.compterJetons = function * (str) {
totalWords = str.split(' ').length;
while(compte < totalWords) {
for(i=0;i<10000000;i++){}
++compte;
pourcent = Math.round(compte*100/totalWords);
yield this.getProgress();
}
}
}