-
Notifications
You must be signed in to change notification settings - Fork 0
/
6-exercise.js
36 lines (36 loc) · 1.18 KB
/
6-exercise.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
var Like = /** @class */ (function () {
function Like(_highlighted, _likes) {
if (_highlighted === void 0) { _highlighted = false; }
if (_likes === void 0) { _likes = 0; }
this._highlighted = _highlighted;
this._likes = _likes;
}
Like.prototype.buttonOnClick = function () {
if (!this._highlighted)
this._likes++;
else
this._likes--;
this._highlighted = !this._highlighted;
};
Object.defineProperty(Like.prototype, "highlighted", {
get: function () {
return this._highlighted;
},
enumerable: false,
configurable: true
});
Object.defineProperty(Like.prototype, "likes", {
get: function () {
return this._likes;
},
enumerable: false,
configurable: true
});
return Like;
}());
var like = new Like(true, 10);
console.log("Highlight: ".concat(like.highlighted, ", Count:").concat(like.likes));
like.buttonOnClick();
console.log("Highlight: ".concat(like.highlighted, ", Count:").concat(like.likes));
like.buttonOnClick();
console.log("Highlight: ".concat(like.highlighted, ", Count:").concat(like.likes));