Closed frankcollins3 closed 1 year ago
ternary value:
monsterHealth = (monsterHealth -= attackStr < 0) ? 0 : -= attackStr;
looks like -= cant be used in that comparison expression: [9:20am]
was pretty close. chatGPT showed me that the falsy block must redeclare the original expression.
I believe what I was trying to do would've worked in JS/JSX-react-code
the monsters health bar is down to: 2 after being hit for: 4 👍 the monsters health bar is down to: 0 after being hit for: 6 // 2 doesn't become - 4 👍 the hero is not attacked after the monster is dead [9:26am]
their answer:
my answer: [9:29am]
attempting to do: game solved [x]; game makes 100% sense[];
error: this above problem
^
was solved with this below approachv
with a condition that checks if health isn't zero yet:new err since fixing that error of monster coming back from dead for final attack (which seems gamey in itself anyways):
the monsters health bar is down to: 👎 -5 after being hit for: 6
// health went from 1 to - 5 which should be 1 to 0proposed approach: something like this that ternary: truthy declares the new health to be 0 if the health went below zero falsy performs the attack as it originally did which works as intended by decrementing healthbar by randomly generated val