/**
* Hello!
* Below are some questions to measure your exposure to
* JavaScript syntax and some core concepts. Don't worry
* if you don't know the answer, just give it a whirl
* and see how far you can get.
*
* Don't forget to use
* console.log(value);
* To echo results to the console
*/
// 1. Declare a variable "myArray" and reference an array of 3 values (colors?)
var myarray = [1,2,3];
var myarray = ["A","B","C"];
var myarray = new array("AC","BC","CD")
// 2. Declare a variable "person" and reference an object with 2 properties, "name", which is your name, and "toString", which is a function that returns the name value.
var person ={
name: "Ranganath",
toString: function(){
return this.name;
}
};
// 3. Create a function that returns either "elf" or "dwarf", based on a random number
// If less than 0.5, return "elf"
// If more than or equal to 0.5, return "dwarf"
function a(i){
if i<0.5
return "elf"
else if i=>0.5
return "dwarf"
}
// 4. Create a function that iterates over an array and logs each value to the console. Invoke the function passing "myArray" (from above) as the argument.
// 5. Create a new object called "me" that uses "person", the object you created up above, as its prototype.
// 6. "call" your "toString" function from the "person" object in the context of the "me" object.
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.