Merge branch 'staging' of github.com:FreeCodeCamp/freecodecamp into staging
This commit is contained in:
@ -1042,7 +1042,7 @@
|
||||
"id":"cf1111c1c12feddfaeb8bdef",
|
||||
"name":"Finding WhiteSpace",
|
||||
"dashedName":"waypoint-finding-whitespace",
|
||||
"difficulty":"9.987",
|
||||
"difficulty":"9.986",
|
||||
"description":[
|
||||
"",
|
||||
"We can also use selectors like <code>\\s</code> to find spaces in a string",
|
||||
@ -1073,20 +1073,20 @@
|
||||
"id":"cf1111c1c12feddfaeb9bdef",
|
||||
"name":"Creating a slots machine",
|
||||
"dashedName":"creating-a-slots-machine",
|
||||
"difficulty":"9.987",
|
||||
"difficulty":"9.988",
|
||||
"description":[
|
||||
"",
|
||||
"We are now going to try and combine some of the stuff we've just learnt abd create the logic for a slot machine game",
|
||||
"For this we will need to generate three random numbers between <code>1</code> and <code>5</code> to represent the possible values of each individual slot",
|
||||
"Store the three random numbers in <code>slotOne</code>, <code>slotTwo</code> and <code>slotThree</code>",
|
||||
"Generate the random numbers by using the system we used earlier in /challenges/random-whole-numbers-in-a-range",
|
||||
"<code> Math.floor(Math.random() * (5 - 1 + 1)) + 1; </code>"
|
||||
"<code> Math.floor(Math.random() * (5 - 1 + 1)) + 1; </code>."
|
||||
],
|
||||
"tests":[
|
||||
"assert(typeof(runSlots($('.slot'))[0]) == 'number', 'SlotOne should be a random number');",
|
||||
"assert(typeof(runSlots($('.slot'))[1]) == 'number', 'SlotTwo should be a random number');",
|
||||
"assert(typeof(runSlots($('.slot'))[2]) == 'number', 'SlotThree should be a random number');",
|
||||
"assert(editorValue.match(/Math.floor\\(Math.random\\(\\) \\* \\(5 \\- 1 \\+ 1\\)\\) \\+ 1/g).length === 3);"
|
||||
"assert((function(){if(editor.match(/Math.floor\\(Math\\.random\\(\\)\\s\\*\\s\\(5\\s\\-\\s1\\s\\+\\s1\\)\\)\\s\\+\\s1;/gi) !== null){return(editor.match(/Math.floor\\(Math\\.random\\(\\)\\s\\*\\s\\(5\\s\\-\\s1\\s\\+\\s1\\)\\)\\s\\+\\s1;/gi).length >= 3);}else{return(false);}})(), 'You should have used Math.floor(Math.random() * (5 - 1 + 1)) + 1; three times to generate your random numbers');"
|
||||
],
|
||||
"challengeSeed":[
|
||||
"fccss",
|
||||
@ -1103,6 +1103,9 @@
|
||||
" ",
|
||||
" /*Don't modify below here*/",
|
||||
" ",
|
||||
" $('.logger').html('');",
|
||||
" $('.logger').html('Not A Win')",
|
||||
" ",
|
||||
" if(slotOne !== undefined && slotTwo !== undefined && slotThree !== undefined){",
|
||||
" $('.logger').html(slotOne + ' ' + slotTwo + ' ' + slotThree);",
|
||||
" }",
|
||||
@ -1119,6 +1122,7 @@
|
||||
"<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'>",
|
||||
@ -1145,54 +1149,59 @@
|
||||
" </div>",
|
||||
"</div>",
|
||||
"",
|
||||
"<link href='http://fonts.googleapis.com/css?family=Lobster' rel='stylesheet' type='text/css'>",
|
||||
"",
|
||||
"<style>",
|
||||
" .container {",
|
||||
" background-color: darkred;",
|
||||
" background-color: #4a2b0f;",
|
||||
" height: 400px;",
|
||||
" width: 260px;",
|
||||
" margin: 50px auto;",
|
||||
" border-radius: 4px;",
|
||||
" }",
|
||||
" .header {",
|
||||
" border: 2px solid gold;",
|
||||
" border: 2px solid #fff;",
|
||||
" border-radius: 4px;",
|
||||
" height: 50px;",
|
||||
" height: 55px;",
|
||||
" margin: 14px auto;",
|
||||
" background-color: #457f86",
|
||||
" }",
|
||||
" .header h2 {",
|
||||
" font-size: 24px;",
|
||||
" margin: 10px 30px;",
|
||||
" height: 30px;",
|
||||
" margin: auto;",
|
||||
" }",
|
||||
" .header h2 {",
|
||||
" font-size: 14px;",
|
||||
" margin: 0 0;",
|
||||
" padding: 0;",
|
||||
" font-family: lobster;",
|
||||
" color: gold;",
|
||||
" color: #fff;",
|
||||
" text-align: center;",
|
||||
" }",
|
||||
" .slots{",
|
||||
" display: flex;",
|
||||
" background-color: rgb(90, 1, 1);",
|
||||
" background-color: #457f86;",
|
||||
" border-radius: 6px;",
|
||||
" border: 2px solid #fff;",
|
||||
" }",
|
||||
" .slot{",
|
||||
" flex: 1 0 auto;",
|
||||
" background: white;",
|
||||
" height: 75px;",
|
||||
" margin: 8px;",
|
||||
" border: 2px solid brown;",
|
||||
" border: 2px solid #215f1e;",
|
||||
" border-radius: 4px;",
|
||||
" }",
|
||||
" .go {",
|
||||
" width: 100%;",
|
||||
" color: gold;",
|
||||
" background-color: rgb(90, 1, 1);",
|
||||
" border: 2px solid gold;",
|
||||
" color: #fff;",
|
||||
" background-color: #457f86;",
|
||||
" border: 2px solid #fff;",
|
||||
" border-radius: 2px;",
|
||||
" box-sizing: none;",
|
||||
" outline: none!important;",
|
||||
" }",
|
||||
" .foot {",
|
||||
" height: 150px;",
|
||||
" background-color: rgb(90,1,1);",
|
||||
" background-color: 457f86;",
|
||||
" border: 2px solid #fff;",
|
||||
" }",
|
||||
" ",
|
||||
" .logger {",
|
||||
@ -1219,20 +1228,23 @@
|
||||
"id":"cf1111c1c13feddfaeb1bdef",
|
||||
"name":"Setting Up The Slot Machine Slots",
|
||||
"dashedName":"setting-up-the-slot-machine-slots",
|
||||
"difficulty":"9.987",
|
||||
"difficulty":"9.989",
|
||||
"description":[
|
||||
"",
|
||||
"Now that we have our random numbers we need to go and check for when they are all the same that means we should count it as a win",
|
||||
"Different numbers will have different values so we need to return the matched number or null",
|
||||
"If we get a match we should change the value of win to the number that we have three of or leave it as null",
|
||||
"Let's create an if statement with multiple conditions to check that all the numbers are equal"
|
||||
"Let's create an if statement with multiple conditions to check that all the numbers are equal",
|
||||
"<code>if(slotOne !== slotTwo || slotTwo !== slotThree){",
|
||||
" return(null);",
|
||||
"}</code>"
|
||||
],
|
||||
"tests":[
|
||||
"assert((function(){var data = runSlots();if(data == null){return(true)}else{if(data[0] == data[1] && data[1] == data[2]){return(true);}else{return(false);}}})(), 'If all three of our random numbers are the same we should return that number. Otherwise we should return null');"
|
||||
],
|
||||
"challengeSeed":[
|
||||
"fccss",
|
||||
" function runSlots(slots){",
|
||||
" function runSlots(){",
|
||||
" var slotOne;",
|
||||
" var slotTwo;",
|
||||
" var slotThree;",
|
||||
@ -1244,6 +1256,7 @@
|
||||
" slotThree = Math.floor(Math.random() * (5 - 1 + 1)) + 1;",
|
||||
" ",
|
||||
" $('.logger').html('');",
|
||||
" $('.logger').html('Not A Win')",
|
||||
" ",
|
||||
" /*Don't modify above here*/",
|
||||
" ",
|
||||
@ -1261,7 +1274,7 @@
|
||||
"",
|
||||
" $(document).ready(function(){",
|
||||
" $('.go').click(function(){",
|
||||
" runSlots(slots);",
|
||||
" runSlots();",
|
||||
" });",
|
||||
" });",
|
||||
"fcces",
|
||||
@ -1269,6 +1282,7 @@
|
||||
"<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'>",
|
||||
@ -1295,56 +1309,59 @@
|
||||
" </div>",
|
||||
"</div>",
|
||||
"",
|
||||
"<link href='http://fonts.googleapis.com/css?family=Lobster' rel='stylesheet' type='text/css'>",
|
||||
"",
|
||||
"<style>",
|
||||
" .container {",
|
||||
" background-color: darkred;",
|
||||
" background-color: #4a2b0f;",
|
||||
" height: 400px;",
|
||||
" width: 260px;",
|
||||
" margin: 50px auto;",
|
||||
" border-radius: 4px;",
|
||||
" }",
|
||||
" .header {",
|
||||
" border: 2px solid gold;",
|
||||
" border: 2px solid #fff;",
|
||||
" border-radius: 4px;",
|
||||
" height: 50px;",
|
||||
" height: 55px;",
|
||||
" margin: 14px auto;",
|
||||
" background-color: #457f86",
|
||||
" }",
|
||||
" .header h2 {",
|
||||
" font-size: 24px;",
|
||||
" margin: 10px 30px;",
|
||||
" height: 30px;",
|
||||
" margin: auto;",
|
||||
" }",
|
||||
" .header h2 {",
|
||||
" font-size: 14px;",
|
||||
" margin: 0 0;",
|
||||
" padding: 0;",
|
||||
" font-family: lobster;",
|
||||
" color: gold;",
|
||||
" color: #fff;",
|
||||
" text-align: center;",
|
||||
" }",
|
||||
" .slots{",
|
||||
" display: flex;",
|
||||
" background-color: rgb(90, 1, 1);",
|
||||
" background-color: #457f86;",
|
||||
" border-radius: 6px;",
|
||||
" border: 2px solid #fff;",
|
||||
" }",
|
||||
" .slot{",
|
||||
" flex: 1 0 auto;",
|
||||
" background: white;",
|
||||
" height: 75px;",
|
||||
" margin: 8px;",
|
||||
" border: 2px solid brown;",
|
||||
" border: 2px solid #215f1e;",
|
||||
" border-radius: 4px;",
|
||||
" text-align: center;",
|
||||
" padding-top: 25px;",
|
||||
" }",
|
||||
" .go {",
|
||||
" width: 100%;",
|
||||
" color: gold;",
|
||||
" background-color: rgb(90, 1, 1);",
|
||||
" border: 2px solid gold;",
|
||||
" color: #fff;",
|
||||
" background-color: #457f86;",
|
||||
" border: 2px solid #fff;",
|
||||
" border-radius: 2px;",
|
||||
" box-sizing: none;",
|
||||
" outline: none!important;",
|
||||
" }",
|
||||
" .foot {",
|
||||
" height: 150px;",
|
||||
" background-color: rgb(90,1,1);",
|
||||
" background-color: 457f86;",
|
||||
" border: 2px solid #fff;",
|
||||
" }",
|
||||
" ",
|
||||
" .logger {",
|
||||
@ -1371,7 +1388,7 @@
|
||||
"id":"cf1111c1c13feddfaeb2bdef",
|
||||
"name":"Giving The Slot Machine Life",
|
||||
"dashedName":"giving-the-slot-machine-life",
|
||||
"difficulty":"9.987",
|
||||
"difficulty":"9.990",
|
||||
"description":[
|
||||
"",
|
||||
"Now we can detect a win let's get the slot machine to look like it works",
|
||||
@ -1382,11 +1399,12 @@
|
||||
"Use the above selector to display each number in the corresponding slot"
|
||||
],
|
||||
"tests":[
|
||||
"assert((function(){if($($('.slot')[0]).html() !== '' && $($('.slot')[1]).html() !== '' $($('.slot')[2]).html() !== ''){return(true);}else{return(false);}})(), '');"
|
||||
"assert((function(){runSlots();if($($('.slot')[0]).html().replace(/\\s/gi, '') !== '' && $($('.slot')[1]).html().replace(/\\s/gi, '') !== '' && $($('.slot')[2]).html().replace(/\\s/gi, '') !== ''){return(true);}else{return(false);}})(), 'You should be displaying the result of the slot numbers in the corresponding slots');",
|
||||
"assert((function(){if(editor.match( /\\$\\(\\$\\(\\'\\.slot\\'\\)\\[\\d\\]\\)/gi )){if(editor.match( /\\$\\(\\$\\(\\'\\.slot\\'\\)\\[\\d\\]\\)/gi ).length >= 3 && editor.match( /\\.html\\(slotOne\\);/gi ) && editor.match( /\\.html\\(slotTwo\\);/gi ) && editor.match( /\\.html\\(slotThree\\);/gi )){return(true);}else{return(false);}}else{return(false);}})(), 'You should have used the the selector given in the description to select each slot and assign it the value of slotOne, slotTwo and slotThree respectively');"
|
||||
],
|
||||
"challengeSeed":[
|
||||
"fccss",
|
||||
" function runSlots(slots){",
|
||||
" function runSlots(){",
|
||||
" var slotOne;",
|
||||
" var slotTwo;",
|
||||
" var slotThree;",
|
||||
@ -1399,10 +1417,7 @@
|
||||
" slotThree = Math.floor(Math.random() * (5 - 1 + 1)) + 1;",
|
||||
" ",
|
||||
" $('.logger').html('');",
|
||||
" ",
|
||||
" if(slotOne != slotTwo || slotTwo != slotThree){",
|
||||
" return(null);",
|
||||
" }",
|
||||
" $('.logger').html('Not A Win')",
|
||||
" ",
|
||||
" /*Don't modify above here*/",
|
||||
" ",
|
||||
@ -1410,17 +1425,22 @@
|
||||
" ",
|
||||
" /*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(slots);",
|
||||
" runSlots();",
|
||||
" });",
|
||||
" });",
|
||||
"fcces",
|
||||
@ -1428,6 +1448,7 @@
|
||||
"<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'>",
|
||||
@ -1454,56 +1475,61 @@
|
||||
" </div>",
|
||||
"</div>",
|
||||
"",
|
||||
"<link href='http://fonts.googleapis.com/css?family=Lobster' rel='stylesheet' type='text/css'>",
|
||||
"",
|
||||
"<style>",
|
||||
" .container {",
|
||||
" background-color: darkred;",
|
||||
" background-color: #4a2b0f;",
|
||||
" height: 400px;",
|
||||
" width: 260px;",
|
||||
" margin: 50px auto;",
|
||||
" border-radius: 4px;",
|
||||
" }",
|
||||
" .header {",
|
||||
" border: 2px solid gold;",
|
||||
" border: 2px solid #fff;",
|
||||
" border-radius: 4px;",
|
||||
" height: 50px;",
|
||||
" height: 55px;",
|
||||
" margin: 14px auto;",
|
||||
" background-color: #457f86",
|
||||
" }",
|
||||
" .header h2 {",
|
||||
" font-size: 24px;",
|
||||
" margin: 10px 30px;",
|
||||
" height: 30px;",
|
||||
" margin: auto;",
|
||||
" }",
|
||||
" .header h2 {",
|
||||
" font-size: 14px;",
|
||||
" margin: 0 0;",
|
||||
" padding: 0;",
|
||||
" font-family: lobster;",
|
||||
" color: gold;",
|
||||
" color: #fff;",
|
||||
" text-align: center;",
|
||||
" }",
|
||||
" .slots{",
|
||||
" display: flex;",
|
||||
" background-color: rgb(90, 1, 1);",
|
||||
" background-color: #457f86;",
|
||||
" border-radius: 6px;",
|
||||
" border: 2px solid #fff;",
|
||||
" }",
|
||||
" .slot{",
|
||||
" flex: 1 0 auto;",
|
||||
" background: white;",
|
||||
" height: 75px;",
|
||||
" margin: 8px;",
|
||||
" border: 2px solid brown;",
|
||||
" border: 2px solid #215f1e;",
|
||||
" border-radius: 4px;",
|
||||
" text-align: center;",
|
||||
" padding-top: 25px;",
|
||||
" }",
|
||||
" .go {",
|
||||
" width: 100%;",
|
||||
" color: gold;",
|
||||
" background-color: rgb(90, 1, 1);",
|
||||
" border: 2px solid gold;",
|
||||
" color: #fff;",
|
||||
" background-color: #457f86;",
|
||||
" border: 2px solid #fff;",
|
||||
" border-radius: 2px;",
|
||||
" box-sizing: none;",
|
||||
" outline: none!important;",
|
||||
" }",
|
||||
" .foot {",
|
||||
" height: 150px;",
|
||||
" background-color: rgb(90,1,1);",
|
||||
" background-color: 457f86;",
|
||||
" border: 2px solid #fff;",
|
||||
" }",
|
||||
" ",
|
||||
" .logger {",
|
||||
|
Reference in New Issue
Block a user