Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>
<body>
</body>
</html>
 
class Animal {
    constructor (name, fly=false, sound) {
        this.name = name
        this.fly = fly
        this.sound = sound
    }
    canFly (fly) {
      if(this.fly) {
        return 'goes up up in the sky'
      }
      return 'stays on the ground'
    }
    talk (sound) {
      return this.sound;
    }
    describe () {
console.log(`${this.name}
${this.canFly()}
and shouts ${this.talk()}`)
    }
}
var bird = new Animal('birdy', true, 'tchirp')
var cat  = new Animal('kitty', false, 'miao')
var strangething  = new Animal()
bird.describe()
cat.describe()
strangething.describe()
Output 300px

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
escapedcatpro
0viewers