/
example.js
74 lines (62 loc) · 1.35 KB
/
example.js
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/**
* @header Example App
* @description Used to show off how cool updoc is.
* Spoiler warning: it's <em>really cool</em>.
*/
/**
* @module guesser
* @header Guesser module
* @description The main application
*/
/**
* @module util
* @header Util Module
* @description Back door debugging stuff
*/
window.example = (function() {
/**
* @module guesser
* @description Can't guess this from outside the module.
* Is a value from 1 to 10
*/
var SECRET = numBetween(1, 10);
/**
* @header Math
* @module util.math
* @description Useful math utilities
*/
/**
* @module util.math
* @description Create random number between x and y
* @param x number
* @param y number
* @return number
*/
function numBetween(x, y) {
return Math.round(Math.random() * (y - 1) + 1 + x);
}
return {
/**
* @module guesser
* @param guessed value
* @description Guess what the secret value is
* @return true or false
*/
guess: function(v) {
return v === SECRET;
},
/**
* @header Cheating
* @module util.cheating
* @description For development only!
*/
/**
* @module util.cheating
* @description Cheat and learn the secret value
* @return a number 1-10
*/
cheat: function() {
return SECRET;
}
};
})();