// Remember to overwite the code in CodeShare, JSFiddle, etc. to restore the inital state of the test and to avoid // showing to candidates the changes made during other interwies // TASKS: // 1. Ask to developer to go through the file and analyze it. The dev should notice: // - Constructor (at this point we can talk also about classes in ES6 // - Destructuring // - String interpolation // - Context (and should notice (and fix) that the callback passed to the onclick will log "I'm a button and I undefined" because it's not bound to // the context ('dog') function Animal({ type, sound, action }) { this.type = type; this.sound = sound; this.action = function() { console.log(`I'm a ${this.type} and I ${this.sound}`); } } const dog = new Animal({ type: 'dog', sound: 'bark' }) dog.action(); const barkButton = document.createElement('input'); barkButton.type = 'button'; barkButton.value = 'Bark !'; barkButton.onclick = dog.action; document.getElementsByTagName('body')[0].appendChild(barkButton);