-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake_them_bark.js
40 lines (31 loc) · 1.2 KB
/
make_them_bark.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*
Make them bark
You have been hired by a dogbreeder to
write a program to keep record of his dogs.
You've already made a constructor Dog,
so no one has to hardcode every puppy.
The work seems to be done. It's high time to collect the payment.
..hold on! The dogbreeder says he wont pay you,
until he can make every dog object .bark(). Even the ones
already done with your constructor.
"Every dog barks" he says.
He also refuses to rewrite them, lazy as he is.
You can't even count how much objects that bastard client of
yours already made. He has a lot of dogs, and none of them can .bark().
Can you solve this problem, or will you let this client
outsmart you for good?
Practical info:
The .bark() method of a dog should return the string 'Woof!'.
The contructor you made (it is preloaded) looks like this:
function Dog(name, breed, sex, age){
this.name = name;
this.breed = breed;
this.sex = sex;
this.age = age;
}
Hint: A friend of yours just told you about how javascript
handles classes diferently from other programming languages.
He couldn't stop ranting about "prototypes", or something like that.
Maybe that could help you...
*/
Dog.prototype.bark= function() {return 'Woof!';}