From de01c6184d9adc4e57fa84bf690aa89ad946e325 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Oddsson?= Date: Sun, 14 Feb 2016 16:41:53 +0000 Subject: [PATCH] Check if the strings 'for' and 'while' in function --- exercises/async_loops/exercise.js | 9 +++++++++ i18n/en.json | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/exercises/async_loops/exercise.js b/exercises/async_loops/exercise.js index b084927..ed963c3 100644 --- a/exercises/async_loops/exercise.js +++ b/exercises/async_loops/exercise.js @@ -41,6 +41,15 @@ module.exports = runner.custom(function(f) { clearTimeout(tooLong) console.log(submittedUsers) + var functionAsAString = fx.toString(); + if ( + functionAsAString.indexOf('for') !== -1 || + functionAsAString.indexOf('while') !== -1 + ) { + self.emit('fail', self.__('used_loops')); + return callback(null, false); + } + if (!deepEqual(submittedUsers, users)) { self.emit('fail', self.__('bad_result', inspect(users), inspect(submittedUsers))) return callback(null, false) diff --git a/i18n/en.json b/i18n/en.json index 6e1f8ee..c028eea 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -40,7 +40,8 @@ "Async Loops": { "all_loaded": "All %d users loaded!", "bad_result": "expected: \n%s\n but got:\n%s", - "took_too_long": "Took too long!" + "took_too_long": "Took too long!", + "used_loops": "Used a loop!", }, "Currying": { "five_words": "This,problem,has,been,solved"