We're a place where coders share, stay up-to-date and grow their careers.
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);
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.
hits: 1, damage: 33, health: 67
I did it!
The following is my solution in javascript:
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.