From 3e264eb419017cd1a87d3dbf4c7a2e31fefdb456 Mon Sep 17 00:00:00 2001 From: Eric Leung Date: Fri, 27 Nov 2015 18:29:13 -0800 Subject: [PATCH] Add test to check for editing of first line of code --- challenges/basic-javascript.json | 1 + 1 file changed, 1 insertion(+) diff --git a/challenges/basic-javascript.json b/challenges/basic-javascript.json index 14b153ebb3..e820eaf384 100644 --- a/challenges/basic-javascript.json +++ b/challenges/basic-javascript.json @@ -1065,6 +1065,7 @@ "Let's use this technique to generate and return a random whole number between 0 and 9." ], "tests": [ + "assert(editor.getValue().match(/var\\srandomNumberBetween0and19\\s=\\sMath.floor\\(Math.random\\(\\)\\s\\*\\s20\\);/).length == 1, 'message: The first line of code should not be changed.');", "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.');",