Non-tested slot machine challenges. Leaving out one challenge as it will require slot machine images to be created and hosted in a static location

This commit is contained in:
benmcmahon100
2015-07-31 19:53:21 +01:00
parent f49f0ccf07
commit a827e2c846

View File

@ -1111,8 +1111,6 @@
" }",
"",
" $(document).ready(function(){",
" var slots = $('.slot');",
" ",
" $('.go').click(function(){",
" runSlots(slots);",
" });",
@ -1228,14 +1226,10 @@
"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",
"",
"<code>This Is Not Done Yet</code>"
"Let's create an if statement with multiple conditions to check that all the numbers are equal"
],
"tests":[
"assert(typeof(runSlots($(''))[0]) == 'number', 'SlotOne should be a random number');",
"assert(typeof(runSlots($(''))[1]) == 'number', 'SlotTwo should be a random number');",
"assert(typeof(runSlots($(''))[2]) == 'number', 'SlotThree should be a random number');",
"assert(editor.getValue().match(/Math.floor\\(Math.random\\(\\) \\* \\(5 \\- 1 \\+ 1\\)\\) \\+ 1/g).length === 3);"
"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",
@ -1246,12 +1240,12 @@
" ",
" var images = ['http://bit.ly/fcc-kittens','http://bit.ly/fcc-kittens','http://bit.ly/fcc-kittens','http://bit.ly/fcc-kittens','http://bit.ly/fcc-kittens'];",
" ",
" var win = null;",
" ",
" 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('');",
" ",
" /*Don't modify above here*/",
" ",
" ",
@ -1259,14 +1253,14 @@
" /*Don't modify below here*/",
" ",
" if(slotOne !== undefined && slotTwo !== undefined && slotThree !== undefined){",
" $('.logger').html(win);",
" $('.logger').html(slotOne);",
" $('.logger').append(' ' + slotTwo);",
" $('.logger').append(' ' + slotThree);",
" }",
" return([slotOne, slotTwo, slotThree]);",
" }",
"",
" $(document).ready(function(){",
" var slots = $('.slot');",
" ",
" $('.go').click(function(){",
" runSlots(slots);",
" });",
@ -1337,6 +1331,166 @@
" margin: 8px;",
" border: 2px solid brown;",
" border-radius: 4px;",
" text-align: center;",
" padding-top: 25px;",
" }",
" .go {",
" width: 100%;",
" color: gold;",
" background-color: rgb(90, 1, 1);",
" border: 2px solid gold;",
" border-radius: 2px;",
" box-sizing: none;",
" outline: none!important;",
" }",
" .foot {",
" height: 150px;",
" background-color: rgb(90,1,1);",
" }",
" ",
" .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>"
],
"challengeType": 0
},
{
"id":"cf1111c1c13feddfaeb2bdef",
"name":"Giving The Slot Machine Life",
"dashedName":"giving-the-slot-machine-life",
"difficulty":"9.987",
"description":[
"",
"Now we can detect a win let's get the slot machine to look like it works",
"We're going to use the jQuery selector <code>$('.slot')</code> to select all of the slots",
"Once they are all selected we can use bracket notation to access each individual one like this",
"<code>$($('.slot')[0])</code>",
"This will grab the the first slot so that we can add the numbers we generate to them",
"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);}})(), '');"
],
"challengeSeed":[
"fccss",
" function runSlots(slots){",
" var slotOne;",
" var slotTwo;",
" var slotThree;",
" ",
" var images = ['http://bit.ly/fcc-kittens','http://bit.ly/fcc-kittens','http://bit.ly/fcc-kittens','http://bit.ly/fcc-kittens','http://bit.ly/fcc-kittens'];",
" ",
" 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('');",
" ",
" if(slotOne != slotTwo || slotTwo != slotThree){",
" return(null);",
" }",
" ",
" /*Don't modify above here*/",
" ",
" ",
" ",
" /*Don't modify below here*/",
" ",
" 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);",
" });",
" });",
"fcces",
" ",
"<div>",
" <div class = 'container inset'>",
" <div class = 'header inset'>",
" <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>",
"",
"<link href='http://fonts.googleapis.com/css?family=Lobster' rel='stylesheet' type='text/css'>",
"",
"<style>",
" .container {",
" background-color: darkred;",
" height: 400px;",
" width: 260px;",
" margin: 50px auto;",
" border-radius: 4px;",
" }",
" .header {",
" border: 2px solid gold;",
" border-radius: 4px;",
" height: 50px;",
" margin: 14px auto;",
" }",
" .header h2 {",
" font-size: 24px;",
" margin: 10px 30px;",
" padding: 0;",
" font-family: lobster;",
" color: gold;",
" }",
" .slots{",
" display: flex;",
" background-color: rgb(90, 1, 1);",
" border-radius: 6px;",
" }",
" .slot{",
" flex: 1 0 auto;",
" background: white;",
" height: 75px;",
" margin: 8px;",
" border: 2px solid brown;",
" border-radius: 4px;",
" text-align: center;",
" padding-top: 25px;",
" }",
" .go {",
" width: 100%;",