2015-07-07 18:54:27 -07:00
{
2015-08-11 15:39:07 +01:00
"name" : "Object Oriented and Functional Programming \n - \n Under Construction From Challenge 4 Onwards" ,
"order" : 0.009 ,
"note" : [
2015-08-12 00:11:56 +01:00
"Waypoint: Closures" ,
"Waypoint: Factories" ,
"Waypoint: Pure Functions" ,
"Waypoint: Currying Functions" ,
"Waypoint: Functors" ,
"Waypoint: Currying Functions"
2015-08-11 15:39:07 +01:00
] ,
2015-07-07 18:54:27 -07:00
"challenges" : [
2015-08-11 15:39:07 +01:00
{
"id" : "cf1111c1c15feddfaeb1bdef" ,
"title" : "Waypoint: A Review On Objects" ,
"difficulty" : 0 ,
"description" : [
"" ,
"Before we dive into Object Oriented Programming Let's take a quick look over objects in javascript"
] ,
"tests" : [
"assert(motorBike.wheels===2, 'You should have given motorBike two wheels');" ,
"assert(motorBike.engine===1, 'You should have given motorBike one engine');" ,
"assert(motorBike.seats===1, 'You should have given motorBike one seat');"
] ,
"challengeSeed" : [
"//Here is a sample Object" ,
"var car = {" ,
" \"wheels\":4," ,
" \"engine\":1," ,
" \"seats\":5" ,
"};" ,
"" ,
"//Now Let's make a similar Object called motorBike" ,
"//Give it two wheels, one engine and one seat" ,
"var motorBike = {" ,
" \"wheels\":0," ,
" \"engine\":0," ,
" \"seats\":0" ,
"};" ,
"" ,
"(function(){return(JSON.stringify(motorBike));})();"
] ,
"challengeType" : 1
} ,
{
"id" : "cf1111c1c15feddfaeb2bdef" ,
"title" : "Waypoint: Constructing Objects" ,
"difficulty" : 0 ,
"description" : [
"" ,
"We are also able to create Objects using functions"
] ,
"tests" : [
"assert((new Car()).wheels === 4, \"myCar.wheels should be four. Make sure that you haven't changed this value\");" ,
"assert(typeof((new Car()).engine) === 'number', 'myCar.engine should be a number');" ,
"assert(typeof((new Car()).seats) === 'number', 'myCar.seats should be a number');"
] ,
"challengeSeed" : [
"//Let's add the properties engine and seats to the car in the same way that the property wheels has been added below. They should both be numbers" ,
"var Car = function(){" ,
" this.wheels = 4;" ,
"};" ,
"" ,
"//Instantiated Here" ,
"var myCar = new Car();" ,
"" ,
"(function(){return(JSON.stringify(myCar));})();"
] ,
"challengeType" : 1
} ,
{
"id" : "cf1111c1c15feddfaeb3bdef" ,
"title" : "Waypoint: Understanding Public and Private Properties" ,
"difficulty" : 0 ,
"description" : [
"" ,
"In the last challenge we use the <code>this</code> to reference public properties the current object or function." ,
"We can also create variables and functions that aren't accessible from outside the Object"
] ,
"tests" : [
2015-08-12 00:11:56 +01:00
"assert(typeof(myBike.getSpeed)!=='undefined' && typeof(myBike.getSpeed) === 'function', 'The method getSpeed of myBike should be accessible outside the Object');" ,
"assert(typeof(myBike.speed) === 'undefined', 'We should not been able');" ,
"assert(typeof(myBike.addUnit === 'undefined'), '');"
2015-08-11 15:39:07 +01:00
] ,
"challengeSeed" : [
"//Let's create an object with a two functions. One attached as a property and one not." ,
"var Car = function(){" ,
" this.gear = 1;" ,
" function addStyle(styleMe){" ,
" return('The Current Gear Is: ' + styleMe);" ,
" }" ,
" this.getGear = function(){" ,
" return(addStyle(this.gear));" ,
" };" ,
"};" ,
"" ,
2015-08-12 00:11:56 +01:00
"//Make the function getSpeed of Bike publicly accessible" ,
2015-08-11 15:39:07 +01:00
"" ,
2015-08-12 00:11:56 +01:00
"var Bike = function(){" ,
" speed = 100;" ,
" function addUnit(value){" ,
" return(value + \"KM/H\");" ,
" }" ,
" " ,
" getSpeed = function (){" ,
" return(addUnit(speed));" ,
" };" ,
" " ,
2015-08-11 15:39:07 +01:00
"};" ,
"" ,
"//Instantiated Here" ,
"var myCar = new Car();" ,
2015-08-12 00:11:56 +01:00
"var myBike = new Bike();" ,
2015-08-11 15:39:07 +01:00
"" ,
2015-08-12 00:11:56 +01:00
"if(myBike.hasOwnProperty('getSpeed')){(function(){return(JSON.stringify(myBike.getSpeed()));})();};"
2015-08-11 15:39:07 +01:00
] ,
"challengeType" : 1
} ,
{
2015-08-12 00:11:56 +01:00
"id" : "cf1111c1c15feddfaeb4bdef" ,
2015-08-11 15:39:07 +01:00
"title" : "Waypoint: Instantiation" ,
"difficulty" : 0 ,
"description" : [
"" ,
"Instantiation at it's most basic level is where you are creating a copy of an object from a template for use at a later time"
] ,
"tests" : [
"assert((new Car()).wheels === 4, 'The property wheels should be four in the object constructor');" ,
"assert(typeof((new Car()).engine) === 'undefined', 'There should not be a property engine in the object constructor');" ,
"assert(myCar.wheels === 4, 'The property wheels of myCar should be four');" ,
"assert(typeof(myCar.engine) === 'number', 'The property engine of myCar should be a number');"
] ,
"challengeSeed" : [
"var Car = function(){" ,
" this.wheels = 4;" ,
"};" ,
"" ,
"var myCar = new Car();" ,
"" ,
"//Add the property engine to myCar using dot notation and make it a number" ,
"" ,
"" ,
"(function(){return(JSON.stringify(myCar));})();"
] ,
"challengeType" : 1
} ,
{
2015-08-12 00:11:56 +01:00
"id" : "cf1111c1c15feddfaeb5bdef" ,
2015-08-11 15:39:07 +01:00
"title" : "Waypoint: Inheritance" ,
"difficulty" : 0 ,
"description" : [
""
] ,
"tests" : [
"assert(1==2, '');"
] ,
"challengeSeed" : [
"Under Construction"
] ,
"challengeType" : 1
} ,
{
2015-08-12 00:11:56 +01:00
"id" : "cf1111c1c15feddfaeb6bdef" ,
2015-08-11 15:39:07 +01:00
"title" : "Waypoint: Prototypical Inheritance" ,
"difficulty" : 0 ,
"description" : [
""
] ,
"tests" : [
"assert(1==2, '');"
] ,
"challengeSeed" : [
"Under Construction"
] ,
"challengeType" : 1
} ,
{
2015-08-12 00:11:56 +01:00
"id" : "cf1111c1c15feddfaeb7bdef" ,
"title" : "Waypoint: Using .map" ,
2015-08-11 15:39:07 +01:00
"difficulty" : 0 ,
"description" : [
""
] ,
"tests" : [
"assert(1==2, '');"
] ,
"challengeSeed" : [
"Under Construction"
] ,
"challengeType" : 1
} ,
{
2015-08-12 00:11:56 +01:00
"id" : "cf1111c1c15feddfaeb8bdef" ,
"title" : "Waypoint: Using .reduce" ,
2015-08-11 15:39:07 +01:00
"difficulty" : 0 ,
"description" : [
""
] ,
"tests" : [
"assert(1==2, '');"
] ,
"challengeSeed" : [
"Under Construction"
] ,
"challengeType" : 1
} ,
{
2015-08-12 00:11:56 +01:00
"id" : "cf1111c1c15feddfaeb9bdef" ,
"title" : "Waypoint: Using .filter" ,
2015-08-11 15:39:07 +01:00
"difficulty" : 0 ,
"description" : [
""
] ,
"tests" : [
"assert(1==2, '');"
] ,
"challengeSeed" : [
"Under Construction"
] ,
"challengeType" : 1
} ,
{
2015-08-12 00:11:56 +01:00
"id" : "cf1111c1c16feddfaeb1bdef" ,
"title" : "Waypoint: Using .sort" ,
2015-08-11 15:39:07 +01:00
"difficulty" : 0 ,
"description" : [
""
] ,
"tests" : [
"assert(1==2, '');"
] ,
"challengeSeed" : [
"Under Construction"
] ,
"challengeType" : 1
} ,
{
2015-08-12 00:11:56 +01:00
"id" : "cf1111c1c16feddfaeb2bdef" ,
"title" : "Waypoint: Using .reverse" ,
"difficulty" : 0 ,
"description" : [
2015-08-11 15:39:07 +01:00
""
] ,
2015-08-12 00:11:56 +01:00
"tests" : [
2015-08-11 15:39:07 +01:00
"assert(1==2, '');"
] ,
2015-08-12 00:11:56 +01:00
"challengeSeed" : [
2015-08-11 15:39:07 +01:00
"Under Construction"
] ,
2015-08-12 00:11:56 +01:00
"challengeType" : 1
2015-08-11 15:39:07 +01:00
} ,
{
2015-08-12 00:11:56 +01:00
"id" : "cf1111c1c16feddfaeb3bdef" ,
"title" : "Waypoint: Using .concat" ,
"difficulty" : 0 ,
"description" : [
2015-08-11 15:39:07 +01:00
""
] ,
2015-08-12 00:11:56 +01:00
"tests" : [
2015-08-11 15:39:07 +01:00
"assert(1==2, '');"
] ,
2015-08-12 00:11:56 +01:00
"challengeSeed" : [
2015-08-11 15:39:07 +01:00
"Under Construction"
] ,
2015-08-12 00:11:56 +01:00
"challengeType" : 1
2015-08-11 15:39:07 +01:00
}
2015-07-07 18:54:27 -07:00
]
}