Skip to content

Instantly share code, notes, and snippets.

@elliotkim916
Created September 19, 2017 00:46
Show Gist options
  • Save elliotkim916/d89a67541ccc839a31df0a6cebdc3954 to your computer and use it in GitHub Desktop.
Save elliotkim916/d89a67541ccc839a31df0a6cebdc3954 to your computer and use it in GitHub Desktop.
Object Drills
function keyDeleter(obj) {
delete obj.foo;
delete obj.bar;
return obj;
}
var sampleObj = {
foo: 'foo',
bar: 'bar',
bizz: 'bizz',
bang: 'bang'
};
function createMyObject() {
return {
foo: 'bar',
answerToUniverse: 42,
'olly olly': 'oxen free',
sayHello: function() {
return 'hello';
}
};
}
function updateObject(obj) {
obj.foo = 'foo';
obj.bar = 'bar';
obj.bizz = 'bizz';
obj.bang = 'bang';
return obj;
}
function personMaker() {
const person = {
firstName: 'Paul',
lastName: 'Jones',
// replace `null` with a function that uses self reference to return
// full name
fullName: function() {
return `${this.firstName} ${this.lastName}`;
}
};
return person;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment