Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
that really helped clear it up. thanks Chrono!
these are the objects listed in the console.
Fighter {
name: 'Cuban',
health: -60,
damagePerAttack: 47,
toString: [Function] }
Fighter {
name: 'Mark',
health: -29,
damagePerAttack: 97,
toString: [Function] }
my code is failing due to two or three of the random tests under the attempt portion, both fighters will start out with negative health. Not sure how to proceed and i really want to finish this one.
in JS
function declareWinner(fighter1, fighter2, firstAttacker) {
let hitC1 = 0;
function whoWon(){
if(fighter1.health > 0){
return fighter1.name;
}
else {
return fighter2.name;
}
}
function secondRound(){
if(fighter1.health > 0 && fighter2.health > 0){
do {
if(hitC1 > 0){
fighter1.health = fighter1.health - fighter2.damagePerAttack;
fighter2.health = fighter2.health - fighter1.damagePerAttack;
}
else {
fighter2.health = fighter2.health - fighter1.damagePerAttack;
fighter1.health = fighter1.health - fighter2.damagePerAttack;
}
}
while (fighter1.health > 0 && fighter2.health > 0)
}
else{
whoWon();
}
}
/below decides first attack/
function fightOn(){
do {
if (firstAttacker === fighter1.name){
fighter2.health = fighter2.health - fighter1.damagePerAttack;
hitC1++;
secondRound();
break;
}
else if(firstAttacker === fighter2.name){
fighter1.health = fighter1.health - fighter2.damagePerAttack;
secondRound();
break;
}
}
while(fighter1.health > 0 && fighter2.health > 0)
}
/below returns outcome of fight/
fightOn();
return whoWon();
}