/**
* Part 1: Create an object that represents yourself
*
* It should have some data (properties):
* Give it your name
* Height? Age? Whatever...
*
* It should have some behaviors (methods)
* Speak? Sit? Stand?
* Dance?
*
* Part 2: Create at least one method, "speak", which accepts a string argument and logs it to the console such as:
* me.speak("hello") => "Tim says: hello"
*
* Part 3: Let’s assume you have a collection of something. Trophies?
* Create an array property on your object that has a couple trophies inside it
*
* Part 4: Add a function that outputs the trophy name to the consold
* me.viewTrophy(i)
* This should log the name of the trophy at index i to the console
*
* Part 5: Add a function that lists trophies to the console
* me.viewTrophy(i);
* This should log a list of trophic names, separated by comma
* ex: “gold star, track, silver medal”
*
* Bonus A: Make the "trophies" property non-enumerable
* Hint: you'll need to use Object.defineProperty()
* Hint: for (var prop in me) {console.log(prop);}
* should not output "trophies" as an enumerable prop
*
* Bonus B: How might we make it so that your trophies are protected?
* Hint: closures
*/
var person =
{
name : "Kavitha",
city : "SF"
toString = function() { return this.name; }
};
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.