From 5f4ecc72e4bde98dadc23e8f91e68c9e95e90e31 Mon Sep 17 00:00:00 2001 From: ahstro Date: Mon, 21 Sep 2015 23:10:13 +0200 Subject: [PATCH] Slot Machine false positives The 'Add your JavaScript Slot Machine Slots' waypoint would throw false positives if all slot numbers were the same, effectively allowing the campers to pass the test without having written any code. --- challenges/basic-javascript.json | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/challenges/basic-javascript.json b/challenges/basic-javascript.json index e3542ee41d..53cc76410b 100644 --- a/challenges/basic-javascript.json +++ b/challenges/basic-javascript.json @@ -1302,7 +1302,7 @@ "}" ], "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.')" + "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 null.')" ], "challengeSeed":[ "fccss", @@ -1485,9 +1485,10 @@ " ", " // Only change code above this line.", " ", - " if(slotOne !== slotTwo || slotTwo !== slotThree){", - " return null;", + " if(slotOne === slotTwo && slotTwo === slotThree){", + " return slotOne;", " }", + " return null;", " ", " if(slotOne !== undefined && slotTwo !== undefined && slotThree !== undefined){", " $(\".logger\").html(slotOne);", @@ -1655,9 +1656,10 @@ " ", " // Only change code above this line.", " ", - " if(slotOne !== slotTwo || slotTwo !== slotThree){", - " return null;", + " if(slotOne === slotTwo && slotTwo === slotThree){", + " return slotOne;", " }", + " return null;", " ", " if(slotOne !== undefined && slotTwo !== undefined && slotThree !== undefined){", " $('.logger').html(slotOne);",