DEV Community

loading...

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

Collapse
alvaromontoro profile image
Alvaro Montoro

JavaScript

const killMonsters = (health, monsters, damage) => 
                         damage * Math.floor((monsters-1) / 3) >= health 
                         ? "hero died" 
                         : `hits: ${Math.floor((monsters-1) / 3)}, damage: ${Math.floor((monsters-1) / 3) * damage}, health: ${health - Math.floor((monsters-1) / 3) * damage}`;

Live demo on CodePen.

Collapse
nishu1343 profile image
nishu1343

I didnot understand this brother. Could u clarify please.

damage * Math.floor((monsters-1) / 3) >= health