{ "name": "Object Oriented and Functional Programming \n - \n Under Construction From Challenge 4 Onwards", "order" : 0.009, "note": [ "Waypoint: Closures", "Waypoint: Factories", "Waypoint: Pure Functions", "Waypoint: Currying Functions", "Waypoint: Functors", "Waypoint: Currying Functions" ], "challenges": [ { "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 this 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":[ "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'), '');" ], "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));", " };", "};", "", "//Make the function getSpeed of Bike publicly accessible", "", "var Bike = function(){", " speed = 100;", " function addUnit(value){", " return(value + \"KM/H\");", " }", " ", " getSpeed = function (){", " return(addUnit(speed));", " };", " ", "};", "", "//Instantiated Here", "var myCar = new Car();", "var myBike = new Bike();", "", "if(myBike.hasOwnProperty('getSpeed')){(function(){return(JSON.stringify(myBike.getSpeed()));})();};" ], "challengeType":1 }, { "id":"cf1111c1c15feddfaeb4bdef", "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 }, { "id":"cf1111c1c15feddfaeb5bdef", "title":"Waypoint: Inheritance", "difficulty":0, "description":[ "" ], "tests":[ "assert(1==2, '');" ], "challengeSeed":[ "Under Construction" ], "challengeType":1 }, { "id":"cf1111c1c15feddfaeb6bdef", "title":"Waypoint: Prototypical Inheritance", "difficulty":0, "description":[ "" ], "tests":[ "assert(1==2, '');" ], "challengeSeed":[ "Under Construction" ], "challengeType":1 }, { "id":"cf1111c1c15feddfaeb7bdef", "title":"Waypoint: Using .map", "difficulty":0, "description":[ "" ], "tests":[ "assert(1==2, '');" ], "challengeSeed":[ "Under Construction" ], "challengeType":1 }, { "id":"cf1111c1c15feddfaeb8bdef", "title":"Waypoint: Using .reduce", "difficulty":0, "description":[ "" ], "tests":[ "assert(1==2, '');" ], "challengeSeed":[ "Under Construction" ], "challengeType":1 }, { "id":"cf1111c1c15feddfaeb9bdef", "title":"Waypoint: Using .filter", "difficulty":0, "description":[ "" ], "tests":[ "assert(1==2, '');" ], "challengeSeed":[ "Under Construction" ], "challengeType":1 }, { "id":"cf1111c1c16feddfaeb1bdef", "title":"Waypoint: Using .sort", "difficulty":0, "description":[ "" ], "tests":[ "assert(1==2, '');" ], "challengeSeed":[ "Under Construction" ], "challengeType":1 }, { "id": "cf1111c1c16feddfaeb2bdef", "title": "Waypoint: Using .reverse", "difficulty": 0, "description": [ "" ], "tests": [ "assert(1==2, '');" ], "challengeSeed": [ "Under Construction" ], "challengeType": 1 }, { "id": "cf1111c1c16feddfaeb3bdef", "title": "Waypoint: Using .concat", "difficulty": 0, "description": [ "" ], "tests": [ "assert(1==2, '');" ], "challengeSeed": [ "Under Construction" ], "challengeType": 1 } ] }