DEV Community

loading...

Discussion on: Daily Challenge #28 - Kill the Monster!

Collapse
ianfabs profile image
Ian Fabs

I did it!

The following is my solution in javascript:

function killMonsters(h, m, dm) {
  let health = h, mh = Math.floor(m/3), hd = mh * dm;
  health -= hd;
  console.log(
    health <= 0
    ? 
    "Hero died"
    : 
    `hits: ${mh}, damage: ${hd}, health: ${health}`
  );
}

killMonsters(100, 3, 33);
killMonsters(50, 7, 10);
Collapse
choroba profile image
E. Choroba

It returns hits: 1, damage: 33, health: 67 for the first input, not the expected output. But my solution does the same...
Update: It doesn't anymore.