Skip to content

Commit 005284f

Browse files
committed
Merge pull request #3 from joshbivens/master
Added simple class example
2 parents 29b2f78 + ad1f233 commit 005284f

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

class.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
/**
22
* Class is a syntactical sugar over prototype based inheritance.
33
*/
4+
class Animal {
5+
constructor(type, sound) {
6+
this.type = type;
7+
this.sound = sound;
8+
}
9+
10+
makeNoise() {
11+
return ('The' + this.type + ' goes ' + this.sound);
12+
}
13+
}
414

5-
//TODO -- Write a simple example for classes
15+
var Simone = new Animal("cat", "meow");
16+
17+
Simone.makeNoise(); // returns "The cat goes meow"

0 commit comments

Comments
 (0)