Skip to content

Commit 93af7b9

Browse files
committed
Merge pull request freeCodeCamp#4260 from faizaanceg/fix-waypoint-javascript-slots
Fix: Refactor Waypoint Javascript Slot Machine
2 parents 3b5b9df + dc11b38 commit 93af7b9

1 file changed

Lines changed: 29 additions & 29 deletions

File tree

seed/challenges/basic-javascript.json

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1332,12 +1332,13 @@
13321332
" ",
13331333
" // Only change code above this line.",
13341334
" ",
1335-
" $(\".logger\").html(\"\");",
1336-
" $(\".logger\").html(\"Not A Win\")",
13371335
" ",
13381336
" if (slotOne !== undefined && slotTwo !== undefined && slotThree !== undefined) {",
13391337
" $(\".logger\").html(slotOne + \" \" + slotTwo + \" \" + slotThree);",
13401338
" }",
1339+
" ",
1340+
" ",
1341+
" $(\".logger\").append(\" Not A Win\")",
13411342
" return [slotOne, slotTwo, slotThree];",
13421343
" }",
13431344
"",
@@ -1459,13 +1460,14 @@
14591460
"title": "Add your JavaScript Slot Machine Slots",
14601461
"description": [
14611462
"Now that our slots will each generate random numbers, we need to check whether they've all returned the same number.",
1462-
"If they have, we should notify our user that they've won.",
1463-
"Otherwise, we should return <code>null</code>, which is a JavaScript data structure that means nothing.",
1464-
"If all three numbers match, we should return the number that we have in three of slots or leave it as <code>null</code>.",
1465-
"Let's create an <code>if statement</code> with multiple conditions in order to check whether all numbers are equal.",
1466-
"<code>if (slotOne !== slotTwo || slotTwo !== slotThree) {</code>",
1463+
"If they have, we should notify our user that they've won and we should return <code>null</code>.",
1464+
"<code>null</code> is a JavaScript data structure that means nothing.",
1465+
"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.",
1466+
"<code>if(slotOne === slotTwo && slotTwo === slotThree){</code>",
14671467
"<code>&nbsp;&nbsp;return null;</code>",
1468-
"<code>}</code>"
1468+
"<code>}</code>",
1469+
"Also, we need to show the user that he has won the game when he gets the same number in all the slots.",
1470+
"If all three numbers match, we should also set the text <code>\"It's A Win\"</code> to the element with class <code>logger</code>."
14691471
],
14701472
"tests": [
14711473
"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>.')"
@@ -1483,20 +1485,19 @@
14831485
" slotTwo = Math.floor(Math.random() * (3 - 1 + 1)) + 1;",
14841486
" slotThree = Math.floor(Math.random() * (3 - 1 + 1)) + 1;",
14851487
" ",
1486-
" $(\".logger\").html(\"\");",
1487-
" $(\".logger\").html(\"Not A Win\");",
14881488
" ",
14891489
" // Only change code below this line.",
14901490
" ",
14911491
" ",
14921492
" ",
14931493
" // Only change code above this line.",
14941494
" ",
1495-
" if (slotOne !== undefined && slotTwo !== undefined && slotThree !== undefined) {",
1496-
" $(\".logger\").html(slotOne);",
1497-
" $(\".logger\").append(\" \" + slotTwo);",
1498-
" $(\".logger\").append(\" \" + slotThree);",
1495+
" if(slotOne !== undefined && slotTwo !== undefined && slotThree !== undefined){",
1496+
" $(\".logger\").html(slotOne + \" \" + slotTwo + \" \" + slotThree);",
14991497
" }",
1498+
" ",
1499+
" $(\".logger\").append(\" Not A Win\");",
1500+
" ",
15001501
" return [slotOne, slotTwo, slotThree];",
15011502
" }",
15021503
"",
@@ -1621,7 +1622,7 @@
16211622
"Let's use the jQuery <code>selector</code> <code>$(\".slot\")</code> to select all of the slots.",
16221623
"Once they are all selected, we can use <code>bracket notation</code> to access each individual slot:",
16231624
"<code>$($(\".slot\")[0]).html(slotOne);</code>",
1624-
"This jQuery will select the first and update the slot's HTML to display the correct number.",
1625+
"This jQuery will select the first slot and update it's HTML to display the correct number.",
16251626
"Use the above selector to display each number in its corresponding slot."
16261627
],
16271628
"tests": [
@@ -1641,8 +1642,6 @@
16411642
" slotTwo = Math.floor(Math.random() * (3 - 1 + 1)) + 1;",
16421643
" slotThree = Math.floor(Math.random() * (3 - 1 + 1)) + 1;",
16431644
" ",
1644-
" $(\".logger\").html(\"\");",
1645-
" $(\".logger\").html(\"Not A Win\")",
16461645
" ",
16471646
" // Only change code below this line.",
16481647
" ",
@@ -1651,15 +1650,17 @@
16511650
" // Only change code above this line.",
16521651
" ",
16531652
" if (slotOne === slotTwo && slotTwo === slotThree) {",
1654-
" return slotOne;",
1653+
" $(\".logger\").html(\" It's A Win\")",
1654+
" return null;",
16551655
" }",
16561656
" ",
1657-
" if (slotOne !== undefined && slotTwo !== undefined && slotThree !== undefined) {",
1658-
" $(\".logger\").html(slotOne);",
1659-
" $(\".logger\").append(\" \" + slotTwo);",
1660-
" $(\".logger\").append(\" \" + slotThree);",
1657+
" if(slotOne !== undefined && slotTwo !== undefined && slotThree !== undefined){",
1658+
" $(\".logger\").html(slotOne + \" \" + slotTwo + \" \" + slotThree);",
16611659
" }",
16621660
" ",
1661+
" $(\".logger\").append(\" Not A Win\");",
1662+
" ",
1663+
" ",
16631664
" return [slotOne, slotTwo, slotThree];",
16641665
" }",
16651666
"",
@@ -1810,8 +1811,6 @@
18101811
" slotTwo = Math.floor(Math.random() * (3 - 1 + 1)) + 1;",
18111812
" slotThree = Math.floor(Math.random() * (3 - 1 + 1)) + 1;",
18121813
" ",
1813-
" $('.logger').html('');",
1814-
" $('.logger').html('Not A Win');",
18151814
" ",
18161815
" // Only change code below this line.",
18171816
" ",
@@ -1820,15 +1819,16 @@
18201819
" // Only change code above this line.",
18211820
" ",
18221821
" if (slotOne === slotTwo && slotTwo === slotThree) {",
1823-
" return slotOne;",
1822+
" $('.logger').html(\"It's A Win\");",
1823+
" return null;",
18241824
" }",
18251825
" ",
1826-
" if (slotOne !== undefined && slotTwo !== undefined && slotThree !== undefined) {",
1827-
" $('.logger').html(slotOne);",
1828-
" $('.logger').append(' ' + slotTwo);",
1829-
" $('.logger').append(' ' + slotThree);",
1826+
" if(slotOne !== undefined && slotTwo !== undefined && slotThree !== undefined){",
1827+
" $(\".logger\").html(slotOne + \" \" + slotTwo + \" \" + slotThree);",
18301828
" }",
18311829
" ",
1830+
" $('.logger').append(\" Not A Win\");",
1831+
" ",
18321832
" return [slotOne, slotTwo, slotThree];",
18331833
" }",
18341834
"",

0 commit comments

Comments
 (0)