From 87ba6f7e082962c734afb528791b1bb04db18d7a Mon Sep 17 00:00:00 2001 From: Logan Tegman Date: Thu, 5 Nov 2015 13:07:39 -0800 Subject: [PATCH] Fix Waypoint Generate Random Whole Numbers Test Closes #4194 --- seed/challenges/basic-javascript.json | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/seed/challenges/basic-javascript.json b/seed/challenges/basic-javascript.json index fd7ac4efcb..78be28fb67 100644 --- a/seed/challenges/basic-javascript.json +++ b/seed/challenges/basic-javascript.json @@ -1062,10 +1062,10 @@ "Let's use this technique to generate and return a random whole number between 0 and 9." ], "tests": [ - "assert(typeof(myFunction()) === \"number\", 'message: The result of myFunction should be a number.');", - "assert(editor.getValue().match(/Math.random/g), 'message: You should be using Math.random to generate a random number.');", + "assert(typeof(myFunction()) === \"number\" && (function(){var r = myFunction();return Math.floor(r) === r;})(), 'message: The result of myFunction should be a whole number.');", + "assert(editor.getValue().match(/Math.random/g).length > 1, 'message: You should be using Math.random to generate a random number.');", "assert(editor.getValue().match(/\\(\\s*?Math.random\\s*?\\(\\s*?\\)\\s*?\\*\\s*?10\\s*?\\)/g) || editor.getValue().match(/\\(\\s*?10\\s*?\\*\\s*?Math.random\\s*?\\(\\s*?\\)\\s*?\\)/g), 'message: You should have multiplied the result of Math.random by 10 to make it a number that is between zero and nine.');", - "assert(editor.getValue().match(/Math.floor/g), 'message: You should use Math.floor to remove the decimal part of the number.');" + "assert(editor.getValue().match(/Math.floor/g).length > 1, 'message: You should use Math.floor to remove the decimal part of the number.');" ], "challengeSeed": [ "var randomNumberBetween0and19 = Math.floor(Math.random() * 20);", @@ -1077,8 +1077,9 @@ " return Math.random();", "", " // Only change code above this line.", - "}", - "", + "}" + ], + "tail":[ "(function(){return myFunction();})();" ], "type": "waypoint",