First four OOP challenges and the final slot machine challenge.
This commit is contained in:
parent
1827857eed
commit
05afe79320
@ -1544,6 +1544,176 @@
|
||||
],
|
||||
"type": "waypoint",
|
||||
"challengeType": 0
|
||||
},
|
||||
{
|
||||
"id":"cf1111c1c11feddfaeb1bdff",
|
||||
"title": "Give your JavaScript Slot Machine some stylish images",
|
||||
"difficulty":"9.9901",
|
||||
"description":[
|
||||
"Now that we can detect when the player wins we are going to add an image to each slot depending on the random values we generate",
|
||||
"<code>$($('.slot')[0]).html('<img src = \"' + images[slotOne-1] + '\">');<code>"
|
||||
],
|
||||
"tests":[
|
||||
"assert(editor.match(/\\$\\(\\$\\(\\'\\.slot\\'\\)\\[\\d\\]\\)\\.html\\(\\'\\<img\\s?src\\s?=\\s?\"\\'\\s?\\+\\s?images\\[\\w+\\-1\\]\\s?\\+\\s?\\'\"\\>\\'\\);/gi) && editor.match(/\\$\\(\\$\\(\\'\\.slot\\'\\)\\[\\d\\]\\)\\.html\\(\\'\\<img\\s?src\\s?=\\s?\"\\'\\s?\\+\\s?images\\[\\w+\\-1\\]\\s?\\+\\s?\\'\"\\>\\'\\);/gi).length >= 3, 'Use the provided code three times. One for each slot');",
|
||||
"assert(editor.match(/slotOne/gi) && editor.match(/slotOne/gi).length >= 7, 'You should have used the slotOne value at least once');",
|
||||
"assert(editor.match(/slotTwo/gi) && editor.match(/slotTwo/gi).length >=8, 'You should have used the slotTwo value at least once');",
|
||||
"assert(editor.match(/slotThree/gi) && editor.match(/slotThree/gi).length >= 7, 'You should have used the slotThree value at least once');"
|
||||
],
|
||||
"challengeSeed":[
|
||||
"fccss",
|
||||
" function runSlots(){",
|
||||
" var slotOne;",
|
||||
" var slotTwo;",
|
||||
" var slotThree;",
|
||||
" ",
|
||||
" //Placeholder",
|
||||
" var images = ['https://www.evernote.com/l/AlxaOC8QrXlBjpTdGMe3mBwLN3Yjm-KB5yQB/image.png','https://www.evernote.com/l/AlyXbeIS8axEspbwXD8RzmsaCUIf10snmzgB/image.png','https://www.evernote.com/l/AlxMveeWtopKaajUmTVrnv92mqA_s2uzW-8B/image.png','https://www.evernote.com/l/AlyyRP_Kh_dCG7t8b4JRnwMNCa1JThI_5gQB/image.png', 'https://www.evernote.com/l/Alx64952qUxEhJnBteZvJgxib1qlwQcw9G0B/image.png'];",
|
||||
" ",
|
||||
" slotOne = Math.floor(Math.random() * (5 - 1 + 1)) + 1;",
|
||||
" slotTwo = Math.floor(Math.random() * (5 - 1 + 1)) + 1;",
|
||||
" slotThree = Math.floor(Math.random() * (5 - 1 + 1)) + 1;",
|
||||
" ",
|
||||
" $('.logger').html('');",
|
||||
" $('.logger').html('Not A Win')",
|
||||
" ",
|
||||
" /*Don't modify above here*/",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" /*Don't modify below here*/",
|
||||
" ",
|
||||
" if(slotOne != slotTwo || slotTwo != slotThree){",
|
||||
" return(null);",
|
||||
" }",
|
||||
" ",
|
||||
" if(slotOne !== undefined && slotTwo !== undefined && slotThree !== undefined){",
|
||||
" $('.logger').html(slotOne);",
|
||||
" $('.logger').append(' ' + slotTwo);",
|
||||
" $('.logger').append(' ' + slotThree);",
|
||||
" }",
|
||||
" ",
|
||||
" return([slotOne, slotTwo, slotThree]);",
|
||||
" }",
|
||||
"",
|
||||
" $(document).ready(function(){",
|
||||
" $('.go').click(function(){",
|
||||
" runSlots();",
|
||||
" });",
|
||||
" });",
|
||||
"fcces",
|
||||
" ",
|
||||
"<div>",
|
||||
" <div class = 'container inset'>",
|
||||
" <div class = 'header inset'>",
|
||||
" <img src='https://s3.amazonaws.com/freecodecamp/freecodecamp_logo.svg.gz' alt='learn to code javascript at Free Code Camp logo' class='img-responsive nav-logo'>",
|
||||
" <h2>FCC Slot Machine</h2>",
|
||||
" </div>",
|
||||
" <div class = 'slots inset'>",
|
||||
" <div class = 'slot inset'>",
|
||||
" ",
|
||||
" </div>",
|
||||
" <div class = 'slot inset'>",
|
||||
" ",
|
||||
" </div>",
|
||||
" <div class = 'slot inset'>",
|
||||
" ",
|
||||
" </div>",
|
||||
" </div>",
|
||||
" <br/>",
|
||||
" <div class = 'outset'>",
|
||||
" <button class = 'go inset'>",
|
||||
" Go",
|
||||
" </button>",
|
||||
" </div>",
|
||||
" <br/>",
|
||||
" <div class = 'foot inset'>",
|
||||
" <span class = 'logger'></span>",
|
||||
" </div>",
|
||||
" </div>",
|
||||
"</div>",
|
||||
"",
|
||||
"<style>",
|
||||
" .slot > img {",
|
||||
" margin: 0!important;",
|
||||
" height: 71px;",
|
||||
" width: 50px;",
|
||||
" }",
|
||||
" .container {",
|
||||
" background-color: #4a2b0f;",
|
||||
" height: 400px;",
|
||||
" width: 260px;",
|
||||
" margin: 50px auto;",
|
||||
" border-radius: 4px;",
|
||||
" }",
|
||||
" .header {",
|
||||
" border: 2px solid #fff;",
|
||||
" border-radius: 4px;",
|
||||
" height: 55px;",
|
||||
" margin: 14px auto;",
|
||||
" background-color: #457f86",
|
||||
" }",
|
||||
" .header h2 {",
|
||||
" height: 30px;",
|
||||
" margin: auto;",
|
||||
" }",
|
||||
" .header h2 {",
|
||||
" font-size: 14px;",
|
||||
" margin: 0 0;",
|
||||
" padding: 0;",
|
||||
" color: #fff;",
|
||||
" text-align: center;",
|
||||
" }",
|
||||
" .slots{",
|
||||
" display: flex;",
|
||||
" background-color: #457f86;",
|
||||
" border-radius: 6px;",
|
||||
" border: 2px solid #fff;",
|
||||
" }",
|
||||
" .slot{",
|
||||
" flex: 1 0 auto;",
|
||||
" background: white;",
|
||||
" height: 75px;",
|
||||
" width: 50px;",
|
||||
" margin: 8px;",
|
||||
" border: 2px solid #215f1e;",
|
||||
" border-radius: 4px;",
|
||||
" text-align: center;",
|
||||
" }",
|
||||
" .go {",
|
||||
" width: 100%;",
|
||||
" color: #fff;",
|
||||
" background-color: #457f86;",
|
||||
" border: 2px solid #fff;",
|
||||
" border-radius: 2px;",
|
||||
" box-sizing: none;",
|
||||
" outline: none!important;",
|
||||
" }",
|
||||
" .foot {",
|
||||
" height: 150px;",
|
||||
" background-color: 457f86;",
|
||||
" border: 2px solid #fff;",
|
||||
" }",
|
||||
" ",
|
||||
" .logger {",
|
||||
" color: white;",
|
||||
" margin: 10px;",
|
||||
" }",
|
||||
" ",
|
||||
" .outset {",
|
||||
" -webkit-box-shadow: 0px 0px 15px -2px rgba(0,0,0,0.75);",
|
||||
" -moz-box-shadow: 0px 0px 15px -2px rgba(0,0,0,0.75);",
|
||||
" box-shadow: 0px 0px 15px -2px rgba(0,0,0,0.75);",
|
||||
" }",
|
||||
" ",
|
||||
" .inset {",
|
||||
" -webkit-box-shadow: inset 0px 0px 15px -2px rgba(0,0,0,0.75);",
|
||||
" -moz-box-shadow: inset 0px 0px 15px -2px rgba(0,0,0,0.75);",
|
||||
" box-shadow: inset 0px 0px 15px -2px rgba(0,0,0,0.75);",
|
||||
" }",
|
||||
"</style>"
|
||||
],
|
||||
"type": "waypoint",
|
||||
"challengeType": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -2,7 +2,12 @@
|
||||
"name": "Object Oriented and Functional Programming \n - \n Under Construction From Challenge 4 Onwards",
|
||||
"order" : 0.009,
|
||||
"note": [
|
||||
"inheritance"
|
||||
"Waypoint: Closures",
|
||||
"Waypoint: Factories",
|
||||
"Waypoint: Pure Functions",
|
||||
"Waypoint: Currying Functions",
|
||||
"Waypoint: Functors",
|
||||
"Waypoint: Currying Functions"
|
||||
],
|
||||
"challenges": [
|
||||
{
|
||||
@ -74,9 +79,9 @@
|
||||
"We can also create variables and functions that aren't accessible from outside the Object"
|
||||
],
|
||||
"tests":[
|
||||
"assert(answers.Q1===true, 'The number Gear is Publicly Accessible');",
|
||||
"assert(answers.Q2===true, 'The function getGear is Publicly Accessible');",
|
||||
"assert(answers.Q3===false, 'The function addStyle is not Publicly Accessible');"
|
||||
"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.",
|
||||
@ -90,33 +95,30 @@
|
||||
" };",
|
||||
"};",
|
||||
"",
|
||||
"//Quick Quiz!",
|
||||
"//Say whether the follow statements are true or false in the answers object below",
|
||||
"//Make the function getSpeed of Bike publicly accessible",
|
||||
"",
|
||||
"//Statement One",
|
||||
"//The number gear publicly accessible",
|
||||
"",
|
||||
"//Statement Two",
|
||||
"//The function getGear publicly accessible",
|
||||
"",
|
||||
"//Statement Three",
|
||||
"//The function addStyle publicly accessible",
|
||||
"",
|
||||
"var answers = {",
|
||||
" 'Q1':false,",
|
||||
" 'Q2':false,",
|
||||
" 'Q3':false",
|
||||
"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();",
|
||||
"",
|
||||
"(function(){return(JSON.stringify(answers));})();"
|
||||
"if(myBike.hasOwnProperty('getSpeed')){(function(){return(JSON.stringify(myBike.getSpeed()));})();};"
|
||||
],
|
||||
"challengeType":1
|
||||
},
|
||||
{
|
||||
"id":"cf1111c1c13feddfaeb6bdef",
|
||||
"id":"cf1111c1c15feddfaeb4bdef",
|
||||
"title":"Waypoint: Instantiation",
|
||||
"difficulty":0,
|
||||
"description":[
|
||||
@ -144,7 +146,7 @@
|
||||
"challengeType":1
|
||||
},
|
||||
{
|
||||
"id":"cf1111c1c13feddfaeb9bdef",
|
||||
"id":"cf1111c1c15feddfaeb5bdef",
|
||||
"title":"Waypoint: Inheritance",
|
||||
"difficulty":0,
|
||||
"description":[
|
||||
@ -159,7 +161,7 @@
|
||||
"challengeType":1
|
||||
},
|
||||
{
|
||||
"id":"cf1111c1c14feddfaeb1bdef",
|
||||
"id":"cf1111c1c15feddfaeb6bdef",
|
||||
"title":"Waypoint: Prototypical Inheritance",
|
||||
"difficulty":0,
|
||||
"description":[
|
||||
@ -174,8 +176,8 @@
|
||||
"challengeType":1
|
||||
},
|
||||
{
|
||||
"id":"cf1111c1c13feddfaeb7bdef",
|
||||
"title":"Waypoint: Closures",
|
||||
"id":"cf1111c1c15feddfaeb7bdef",
|
||||
"title":"Waypoint: Using .map",
|
||||
"difficulty":0,
|
||||
"description":[
|
||||
""
|
||||
@ -189,8 +191,8 @@
|
||||
"challengeType":1
|
||||
},
|
||||
{
|
||||
"id":"cf1111c1c14feddfaeb3bdef",
|
||||
"title":"Waypoint: Factories",
|
||||
"id":"cf1111c1c15feddfaeb8bdef",
|
||||
"title":"Waypoint: Using .reduce",
|
||||
"difficulty":0,
|
||||
"description":[
|
||||
""
|
||||
@ -204,9 +206,8 @@
|
||||
"challengeType":1
|
||||
},
|
||||
{
|
||||
"id":"cf1111c1c14feddfaeb5bdef",
|
||||
"title":"Waypoint: Pure Functions",
|
||||
"Note":"May need a waypoint before each topic to announce what it is :p",
|
||||
"id":"cf1111c1c15feddfaeb9bdef",
|
||||
"title":"Waypoint: Using .filter",
|
||||
"difficulty":0,
|
||||
"description":[
|
||||
""
|
||||
@ -220,8 +221,8 @@
|
||||
"challengeType":1
|
||||
},
|
||||
{
|
||||
"id":"cf1111c1c14feddfaeb6bdef",
|
||||
"title":"Waypoint: Currying Functions",
|
||||
"id":"cf1111c1c16feddfaeb1bdef",
|
||||
"title":"Waypoint: Using .sort",
|
||||
"difficulty":0,
|
||||
"description":[
|
||||
""
|
||||
@ -235,53 +236,34 @@
|
||||
"challengeType":1
|
||||
},
|
||||
{
|
||||
"id":"cf1111c1c14feddfaeb7bdef",
|
||||
"title":"Waypoint: Composition",
|
||||
"difficulty":0,
|
||||
"description":[
|
||||
"id": "cf1111c1c16feddfaeb2bdef",
|
||||
"title": "Waypoint: Using .reverse",
|
||||
"difficulty": 0,
|
||||
"description": [
|
||||
""
|
||||
],
|
||||
"tests":[
|
||||
"tests": [
|
||||
"assert(1==2, '');"
|
||||
],
|
||||
"challengeSeed":[
|
||||
"challengeSeed": [
|
||||
"Under Construction"
|
||||
],
|
||||
"challengeType":1
|
||||
"challengeType": 1
|
||||
},
|
||||
{
|
||||
"id":"cf1111c1c14feddfaeb8bdef",
|
||||
"title":"Waypoint: Functors",
|
||||
"difficulty":0,
|
||||
"description":[
|
||||
"id": "cf1111c1c16feddfaeb3bdef",
|
||||
"title": "Waypoint: Using .concat",
|
||||
"difficulty": 0,
|
||||
"description": [
|
||||
""
|
||||
],
|
||||
"tests":[
|
||||
"tests": [
|
||||
"assert(1==2, '');"
|
||||
],
|
||||
"challengeSeed":[
|
||||
"challengeSeed": [
|
||||
"Under Construction"
|
||||
],
|
||||
"challengeType":1
|
||||
},
|
||||
{
|
||||
"id":"cf1111c1c14feddfaeb9bdef",
|
||||
"title":"Waypoint: Currying Functions",
|
||||
"Notes":[
|
||||
"",
|
||||
""
|
||||
],
|
||||
"difficulty":0,
|
||||
"description":[
|
||||
""
|
||||
],
|
||||
"tests":[
|
||||
"assert(1==2, '');"
|
||||
],
|
||||
"challengeSeed":[
|
||||
"Under Construction"
|
||||
],
|
||||
"challengeType":1
|
||||
"challengeType": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user