refactor waypoint javascript-slots
This commit is contained in:
@ -1333,12 +1333,13 @@
|
||||
" ",
|
||||
" // Only change code above this line.",
|
||||
" ",
|
||||
" $(\".logger\").html(\"\");",
|
||||
" $(\".logger\").html(\"Not A Win\")",
|
||||
" ",
|
||||
" if (slotOne !== undefined && slotTwo !== undefined && slotThree !== undefined) {",
|
||||
" $(\".logger\").html(slotOne + \" \" + slotTwo + \" \" + slotThree);",
|
||||
" }",
|
||||
" ",
|
||||
" ",
|
||||
" $(\".logger\").append(\" Not A Win\")",
|
||||
" return [slotOne, slotTwo, slotThree];",
|
||||
" }",
|
||||
"",
|
||||
@ -1460,13 +1461,14 @@
|
||||
"title": "Add your JavaScript Slot Machine Slots",
|
||||
"description": [
|
||||
"Now that our slots will each generate random numbers, we need to check whether they've all returned the same number.",
|
||||
"If they have, we should notify our user that they've won.",
|
||||
"Otherwise, we should return <code>null</code>, which is a JavaScript data structure that means nothing.",
|
||||
"If all three numbers match, we should return the number that we have in three of slots or leave it as <code>null</code>.",
|
||||
"Let's create an <code>if statement</code> with multiple conditions in order to check whether all numbers are equal.",
|
||||
"<code>if (slotOne !== slotTwo || slotTwo !== slotThree) {</code>",
|
||||
"If they have, we should notify our user that they've won and we should return <code>null</code>.",
|
||||
"<code>null</code> is a JavaScript data structure that means nothing.",
|
||||
"The user wins when all the three numbers match. Let's create an <code>if statement</code> with multiple conditions in order to check whether all numbers are equal.",
|
||||
"<code>if(slotOne === slotTwo && slotTwo === slotThree){</code>",
|
||||
"<code> return null;</code>",
|
||||
"<code>}</code>"
|
||||
"<code>}</code>",
|
||||
"Also, we need to show the user that he has won the game when he gets the same number in all the slots.",
|
||||
"If all three numbers match, we should set the text <code>\"It's A Win\"</code> to the element with class <code>logger</code> or leave it as it is."
|
||||
],
|
||||
"tests": [
|
||||
"assert((function(){var data = runSlots();return data === null || data.toString().length === 1;})(), 'If all three of our random numbers are the same we should return that number. Otherwise we should return <code>null</code>.')"
|
||||
@ -1484,8 +1486,6 @@
|
||||
" slotTwo = Math.floor(Math.random() * (3 - 1 + 1)) + 1;",
|
||||
" slotThree = Math.floor(Math.random() * (3 - 1 + 1)) + 1;",
|
||||
" ",
|
||||
" $(\".logger\").html(\"\");",
|
||||
" $(\".logger\").html(\"Not A Win\");",
|
||||
" ",
|
||||
" // Only change code below this line.",
|
||||
" ",
|
||||
@ -1493,11 +1493,12 @@
|
||||
" ",
|
||||
" // Only change code above this line.",
|
||||
" ",
|
||||
" if (slotOne !== undefined && slotTwo !== undefined && slotThree !== undefined) {",
|
||||
" $(\".logger\").html(slotOne);",
|
||||
" $(\".logger\").append(\" \" + slotTwo);",
|
||||
" $(\".logger\").append(\" \" + slotThree);",
|
||||
" if(slotOne !== undefined && slotTwo !== undefined && slotThree !== undefined){",
|
||||
" $(\".logger\").html(slotOne + \" \" + slotTwo + \" \" + slotThree);",
|
||||
" }",
|
||||
" ",
|
||||
" $(\".logger\").append(\" Not A Win\");",
|
||||
" ",
|
||||
" return [slotOne, slotTwo, slotThree];",
|
||||
" }",
|
||||
"",
|
||||
@ -1622,7 +1623,7 @@
|
||||
"Let's use the jQuery <code>selector</code> <code>$(\".slot\")</code> to select all of the slots.",
|
||||
"Once they are all selected, we can use <code>bracket notation</code> to access each individual slot:",
|
||||
"<code>$($(\".slot\")[0]).html(slotOne);</code>",
|
||||
"This jQuery will select the first and update the slot's HTML to display the correct number.",
|
||||
"This jQuery will select the first slot and update it's HTML to display the correct number.",
|
||||
"Use the above selector to display each number in its corresponding slot."
|
||||
],
|
||||
"tests": [
|
||||
@ -1642,8 +1643,6 @@
|
||||
" slotTwo = Math.floor(Math.random() * (3 - 1 + 1)) + 1;",
|
||||
" slotThree = Math.floor(Math.random() * (3 - 1 + 1)) + 1;",
|
||||
" ",
|
||||
" $(\".logger\").html(\"\");",
|
||||
" $(\".logger\").html(\"Not A Win\")",
|
||||
" ",
|
||||
" // Only change code below this line.",
|
||||
" ",
|
||||
@ -1652,15 +1651,17 @@
|
||||
" // Only change code above this line.",
|
||||
" ",
|
||||
" if (slotOne === slotTwo && slotTwo === slotThree) {",
|
||||
" return slotOne;",
|
||||
" $(\".logger\").html(\" It's A Win\")",
|
||||
" return null;",
|
||||
" }",
|
||||
" ",
|
||||
" if (slotOne !== undefined && slotTwo !== undefined && slotThree !== undefined) {",
|
||||
" $(\".logger\").html(slotOne);",
|
||||
" $(\".logger\").append(\" \" + slotTwo);",
|
||||
" $(\".logger\").append(\" \" + slotThree);",
|
||||
" if(slotOne !== undefined && slotTwo !== undefined && slotThree !== undefined){",
|
||||
" $(\".logger\").html(slotOne + \" \" + slotTwo + \" \" + slotThree);",
|
||||
" }",
|
||||
" ",
|
||||
" $(\".logger\").append(\" Not A Win\");",
|
||||
" ",
|
||||
" ",
|
||||
" return [slotOne, slotTwo, slotThree];",
|
||||
" }",
|
||||
"",
|
||||
@ -1811,8 +1812,6 @@
|
||||
" slotTwo = Math.floor(Math.random() * (3 - 1 + 1)) + 1;",
|
||||
" slotThree = Math.floor(Math.random() * (3 - 1 + 1)) + 1;",
|
||||
" ",
|
||||
" $('.logger').html('');",
|
||||
" $('.logger').html('Not A Win');",
|
||||
" ",
|
||||
" // Only change code below this line.",
|
||||
" ",
|
||||
@ -1821,15 +1820,16 @@
|
||||
" // Only change code above this line.",
|
||||
" ",
|
||||
" if (slotOne === slotTwo && slotTwo === slotThree) {",
|
||||
" return slotOne;",
|
||||
" $('.logger').html(\"It's A Win\");",
|
||||
" return null;",
|
||||
" }",
|
||||
" ",
|
||||
" if (slotOne !== undefined && slotTwo !== undefined && slotThree !== undefined) {",
|
||||
" $('.logger').html(slotOne);",
|
||||
" $('.logger').append(' ' + slotTwo);",
|
||||
" $('.logger').append(' ' + slotThree);",
|
||||
" if(slotOne !== undefined && slotTwo !== undefined && slotThree !== undefined){",
|
||||
" $(\".logger\").html(slotOne + \" \" + slotTwo + \" \" + slotThree);",
|
||||
" }",
|
||||
" ",
|
||||
" $('.logger').append(\" Not A Win\");",
|
||||
" ",
|
||||
" return [slotOne, slotTwo, slotThree];",
|
||||
" }",
|
||||
"",
|
||||
|
Reference in New Issue
Block a user