Fix Waypoint Generate Random Whole Numbers Test

Closes #4194
This commit is contained in:
Logan Tegman
2015-11-05 13:07:39 -08:00
parent 6984ad8f13
commit 87ba6f7e08

View File

@ -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 <code>myFunction</code> 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 <code>myFunction</code> should be a whole 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(/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": [
"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",