It seems like you are trying to pass an object as an argument to the damageCalc() function, but it's being treated as a string. To pass an object as an argument, you need to ensure that you're passing the actual object and not its string representation. Here's how you can do it:
Assuming _monstar is an object and you want to pass it to the damageCalc() function, you should directly pass the object itself without enclosing it in backticks (which are used for template literals to create strings).
Here's the corrected way to pass the object to the function:
// Assuming _monstar is an object
const _monstar = {
status: {
power: [/* some values /]
},
skill: [{
might: / some value */
}]
};
// Call damageCalc() and pass the object directly
damageCalc(_monstar);
Then, within the damageCalc() function, you can access the object's properties as usual:
function damageCalc(_monstar) {
const attack = _monstar.status.power[0] * (_monstar.skill[0].might * 0.025);
const damage = attack - _pokomon.status.defense[0];
currentEnemyHP -= damage;
if (currentEnemyHP <= 0) {
enemyHPGauge.style.width = "0";
} else {
updateGauge(currentEnemyHP, maxEnemyHP, enemyHPGauge);
}
}
y directly passing the object without backticks, you ensure that the function receives the actual object reference, not a string representation.
Thank you.