Open tygamchenry opened 7 years ago
because we don't want lasers only at level 42; we want lasers for all robots that reach level 42 so they keep them after that too. By adding the function to the prototype, you can call deployLaser after you've reached level 42 and gone beyond.
Ok, I can wrap my head around that. Thank you for the prompt responses (again)!
Tyga
On Jul 20, 2017 1:29 PM, "Elisabeth Robson" notifications@github.com wrote:
because we don't want lasers only at level 42; we want lasers for all robots that reach level 42 so they keep them after that too. By adding the function to the prototype, you can call deployLaser after you've reached level 42 and gone beyond.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/bethrobson/Head-First-JavaScript-Programming/issues/20#issuecomment-316790656, or mute the thread https://github.com/notifications/unsubscribe-auth/ARggdhr6d162sFvixbIpx3_aLQKsK_X0ks5sP5yAgaJpZM4OeWQd .
Hello,
Why is a function needed under the unlock function? The following doesn't work... why doesn't it?
Game.prototype.unlock = function() { if (this.level === 42) { console.log(this.name + " is blasting you with laser beams."); } }
...
robby.unlock(); rosie.unlock();