7 kyu

JavaScript class-like objects

10,993 of 11,235jhoffner

Description:

For this exercise you should create a JavaScript class like object called "Animal" that takes in "name" and "type" arguments. It should have a toString method that returns a human readable string indicating the argument information passed in. It should also allow the name property to be set.

The following is an example of how the final code would be used and what the expected return values should be:

let dog = new Animal('Max', 'dog');
dog.toString(); // should return 'Max is a dog'
dog.type; // should == 'dog'
dog.name; // should == 'Max'
dog.name = 'Lassie'; // should set name to 'Lassie'
Object-oriented Programming
Fundamentals

Stats:

CreatedMar 11, 2013
PublishedJun 24, 2013
Warriors Trained14236
Total Skips984
Total Code Submissions38026
Total Times Completed11235
JavaScript Completions10993
Total Stars54
% of votes with a positive feedback rating88% of 526
Total "Very Satisfied" Votes421
Total "Somewhat Satisfied" Votes79
Total "Not Satisfied" Votes26
Ad
Contributors
  • jhoffner Avatar
  • Voile Avatar
  • hobovsky Avatar
Ad