We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 594d1c0 commit 57519ecCopy full SHA for 57519ec
05_dice.js
@@ -0,0 +1,13 @@
1
+// Object Literal For A Dice
2
+var die = {
3
+ size: 6,
4
+ totalRolls: 0,
5
+ roll: function () {
6
+ // this is referring to the object itself
7
+ var result = Math.ceil(this.size * Math.random());
8
+ this.totalRolls += 1;
9
+ return result;
10
+ }
11
+};
12
+
13
+exports.die = die;
05_program.js
@@ -0,0 +1,9 @@
+// Program to use dice.js
+var dice = require("./05_dice");
+var die = dice.die
+die.size = 10;
+console.log(die.roll());
+console.log("Total rolls " + die.totalRolls);
0 commit comments