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
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
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:
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.