I'm building a website with some rpg stat blocks for a table top role playing game I'm trying get a string element to use data from another element. but it when I go to boot up a web browser it prints it as undefined.
These element are part of the same object.
str: 18,
proficiency: 2,
attackroll: "",
Attack: function() {
this.attackroll = ((this.proficiency + Math.floor(((this.str)-10)/2)).toString());
console.log(this.attackroll)
},
actions:"Bite. +" + this.attackroll + " to hit, reach 5ft, one target. Hit: 16 (3d8 + 4 piercing damage).",
When I go to run the HTML it prints:
Bite. +undefined to hit, reach 5ft, one target. Hit: 16 (3d8 + 4 piercing damage).