I am new in node. I'm trying to access object properties and methods with .notation and it is giving undefined error for object properties and "TypeError: dice.roll is not a function " for object functions.
Here is code:
object file:
var dice = {
size: 4,
count:3,
roll:function(){
var result = Math.ceil(this.size * Math.random());
return result;
}
};
exports.diceObjectName = dice;
program file:
var dice = require("./dice");
console.log(dice);
console.log(dice.roll());
console.log(dice)?exports.diceObjectName = dice;intoexports.dice = dice;.