From d4c15339e1562afb22ce99d5166c4d54ae235ddf Mon Sep 17 00:00:00 2001 From: "Andrey.Romanov" Date: Sat, 17 Feb 2018 16:32:18 +0300 Subject: [PATCH] add NAN checking when converting String to Number --- exercises/baby_steps/solution/solution.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/exercises/baby_steps/solution/solution.js b/exercises/baby_steps/solution/solution.js index d479a28a..8be39e38 100644 --- a/exercises/baby_steps/solution/solution.js +++ b/exercises/baby_steps/solution/solution.js @@ -1,7 +1,9 @@ let result = 0 for (let i = 2; i < process.argv.length; i++) { - result += Number(process.argv[i]) + parsedArg = Number(process.argv[i]) + if (isNaN(parsedArg)) continue + result += parsedArg } -console.log(result) +console.log(result) \ No newline at end of file