Skip to content

Instantly share code, notes, and snippets.

@dydx
Last active December 8, 2015 21:04
Show Gist options
  • Save dydx/70ec931c05ac53825188 to your computer and use it in GitHub Desktop.
Save dydx/70ec931c05ac53825188 to your computer and use it in GitHub Desktop.
var billMurray = {
name: "Bill Murray",
age: 65,
movies: [
'Caddy Shack',
'Lost in Translation',
'Ghost Busters'
],
show: function () {
return `
Name: ${this.name}
Age: ${this.age}
Movies: ${this.movies.join(', ')}
`
}
}
console.log(billMurray.show())
var car = {
make: 'BMW',
model: '335i',
year: '2013',
// http://www.writtensound.com/index.php?term=boooOOOOOOooo
symptom: 'boooOOOOOOooo',
complain: function () {
return `this hunk of junk goes ${this.symptom}`
}
}
console.log(car.complain())
var circle = {
radius: 5,
diameter: function () { return this.radius * 2 },
area: function () { return this.radius * this.radius * Math.PI },
stats: function () { return `
The circle's radius is: ${this.radius}
It's diamter is: ${this.diameter()}
And it's area is: ${this.area()}
`}
}
console.log(circle.stats())
> script.js:36
Name: Bill Murray
Age: 65
Movies: Caddy Shack, Lost in Translation, Ghost Busters
> script.js:48
this hunk of junk goes boooOOOOOOooo
> script.js:61
The circle's radius is: 5
It's diamter is: 10
And it's area is: 78.53981633974483
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment