Balloon game problem

Hi, im working on the balloon game challenge and i keep getting a message " Tested with balloonAttack(p1, p2) where p1.hitsPerMinute = 5 and p2.hitsPerMinute = 2 . Result was not 'p1' Its as if my if statement wasnt running.
Could anyone tell me whats wrong with my code ?

class Player {
    constructor(name, hitsPerMinute) {
      this._name = name;
      this._hitsPerMinute = hitsPerMinute;
      this.balloonCount = 100;
    get name() {
      return this._name;
    get hitsPerMinute() {
      return this._hitsPerMinute;
    status() {
      console.log(`Player: ${} -- Balloons Left: ${this.balloonCount}`)

const balloonAttack = (player1, player2) => {
    const player1Shots = player1.hitsPerMinute * 10;
    const player2Shots = player2.hitsPerMinute * 10;

 player1.balloonCount = player1.balloonCount - player2Shots;
 player2.balloonCount = player2.balloonCount - player1Shots;

 if (player1.balloonCount > player2.balloonCount) {
    return `${} is the winner!`
 } else if (player2.balloonCount > player1.balloonCount) {
    return `${} is the winner!`
 } else if (player1.balloonCount === player2.balloonCount) {
    return 'Its a tie!'
const p1 = new Player('p1', 5);
const p2 = new Player('p2', 2);
balloonAttack(p1, p2);

Not to be picky, but this is not a use case for an arrow function. Call it as it is…

const balloonAttack = function (player1, player2) {


Use arrow functions where they make the most sense, not as a replacement for standard function expressions.

Think of arrow functions as in and out. In goes the value, out goes the new value; done like dinner. Else, stick to the ES5 function syntax. Everyone will love you.

Arrow functions are a means of shortening the syntax when verbosity is not required to carry out the function. Bing-bang-boom. They are shortened so that their expressive nature is more visible.

Using an arrow function with multiple lines (statements) runs counter to this principle.

1 Like


I don’t have access to the PRO content at the moment, so I can’t check the instructions to tell you why you do not pass the test. But I can tell you that your if statements do run. But you do not log them to the console, so you cannot see the result:

If you log the function call, you’ll see the returned result:

console.log(balloonAttack(p1, p2)); // logs "p1 is the winner!"

Thanks, I didnt know.

1 Like

Thanks for taking a look! i figured the only issue was, I was only display the winners name with no string!