Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

usha addala
seal-mask
.a{fill-rule:evenodd;}techdegree
usha addala
Full Stack JavaScript Techdegree Student 3,403 Points

item.kill(); what does this method do when its called?

what does this method do when its called?

function itemHandler(player, item) {
  item.kill();
  if (item.key === 'coin') {
     currentScore = currentScore + 10;
  } else if (item.key === 'poison') {
     currentScore = currentScore - 25;
  } else if (item.key === 'star') {
     currentScore = currentScore + 25;
  }
  if (currentScore === winningScore) {
      createBadge();
  }
}

Unit #!

Michael Hulet
Michael Hulet
47,912 Points

It looks like this question didn't get linked to a video/quiz/challenge properly, so it's really difficult to know what item is. Can you post the code that defines it?

Michael Hulet
Michael Hulet
47,912 Points

Hmm, it's still not really clear from that code what kill does. Which video are you following?

1 Answer