Merge pull request #4197 from ltegman/fix/waypoint-random-whole-number-test-4194

Fix Waypoint Generate Random Whole Numbers Test
This commit is contained in:
Rex Schrader
2015-11-11 14:42:16 -08:00

View File

@ -1066,10 +1066,10 @@
"Let's use this technique to generate and return a random whole number between 0 and 9." "Let's use this technique to generate and return a random whole number between 0 and 9."
], ],
"tests": [ "tests": [
"assert(typeof(myFunction()) === \"number\", 'message: The result of <code>myFunction</code> should be a number.');", "assert(typeof(myFunction()) === \"number\" && (function(){var r = myFunction();return Math.floor(r) === r;})(), 'message: The result of <code>myFunction</code> should be a whole number.');",
"assert(editor.getValue().match(/Math.random/g), 'message: You should be using Math.random to generate a random number.');", "assert(editor.getValue().match(/Math.random/g).length > 1, 'message: You should be using <code>Math.random</code> 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 <code>Math.random</code> by 10 to make it a number that is between zero and nine.');", "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 <code>Math.random</code> by 10 to make it a number that is between zero and nine.');",
"assert(editor.getValue().match(/Math.floor/g), 'message: You should use <code>Math.floor</code> to remove the decimal part of the number.');" "assert(editor.getValue().match(/Math.floor/g).length > 1, 'message: You should use <code>Math.floor</code> to remove the decimal part of the number.');"
], ],
"challengeSeed": [ "challengeSeed": [
"var randomNumberBetween0and19 = Math.floor(Math.random() * 20);", "var randomNumberBetween0and19 = Math.floor(Math.random() * 20);",
@ -1081,8 +1081,9 @@
" return Math.random();", " return Math.random();",
"", "",
" // Only change code above this line.", " // Only change code above this line.",
"}", "}"
"", ],
"tail":[
"(function(){return myFunction();})();" "(function(){return myFunction();})();"
], ],
"type": "waypoint", "type": "waypoint",