Who let the dogs out?

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
var BARK = 'woof woof';
var SLEEP = 'zzzzzzzzz....';
function defaults(val, def) {
return val === void 0 ? def : val;
}
function dog_bark_by_default(bark) {
return defaults(bark, true) ? BARK : SLEEP;
}
function dog_bark_only_if_told_so(bark) {
return defaults(bark, false) ? BARK : SLEEP;
}
function dog_dont_bark_by_default(dont_bark) {
return !defaults(dont_bark, true) ? BARK : SLEEP;
}
function dog_dont_bark_only_if_told_so(dont_bark) {
return !defaults(dont_bark, false) ? BARK : SLEEP;
}