From 8ff6d9bff11d461f7cd0b827cdb8f79b1322f5b5 Mon Sep 17 00:00:00 2001 From: Adrian Klimek Date: Tue, 12 Dec 2017 22:37:34 +0100 Subject: [PATCH 1/3] Simplify isEven function --- README.md | 6 +++--- snippets/even-or-odd-number.md | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 640da6cd9..93fbac389 100644 --- a/README.md +++ b/README.md @@ -195,11 +195,11 @@ const escapeRegExp = str => str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); ### Even or odd number -Use `Math.abs()` to extend logic to negative numbers, check using the modulo (`%`) operator. -Return `true` if the number is even, `false` if the number is odd. +Checks whether number is odd or even using the modulo (`%`) operator. +Returns `true` if the number is even, `false` if the number is odd. ```js -const isEven = num => Math.abs(num) % 2 === 0; +const isEven = num => num % 2 === 0; // isEven(3) -> false ``` diff --git a/snippets/even-or-odd-number.md b/snippets/even-or-odd-number.md index 605108429..1399bb593 100644 --- a/snippets/even-or-odd-number.md +++ b/snippets/even-or-odd-number.md @@ -1,9 +1,9 @@ ### Even or odd number -Use `Math.abs()` to extend logic to negative numbers, check using the modulo (`%`) operator. -Return `true` if the number is even, `false` if the number is odd. +Checks whether number is odd or even using the modulo (`%`) operator. +Returns `true` if the number is even, `false` if the number is odd. ```js -const isEven = num => Math.abs(num) % 2 === 0; +const isEven = num => num % 2 === 0; // isEven(3) -> false ``` From 393b1a6a59d30d09fd54988a1fe20fc0fe4e3416 Mon Sep 17 00:00:00 2001 From: Adrian Klimek Date: Tue, 12 Dec 2017 23:11:03 +0100 Subject: [PATCH 2/3] Update the snippet description (odd or even number) --- snippets/even-or-odd-number.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snippets/even-or-odd-number.md b/snippets/even-or-odd-number.md index 1399bb593..24eb312e6 100644 --- a/snippets/even-or-odd-number.md +++ b/snippets/even-or-odd-number.md @@ -1,6 +1,6 @@ ### Even or odd number -Checks whether number is odd or even using the modulo (`%`) operator. +Checks whether a number is odd or even using the modulo (`%`) operator. Returns `true` if the number is even, `false` if the number is odd. ```js From 35c7669773588cac1d802a07ebfae1a0be4e3e36 Mon Sep 17 00:00:00 2001 From: Adrian Klimek Date: Wed, 13 Dec 2017 20:02:29 +0100 Subject: [PATCH 3/3] Build the list --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 93fbac389..12212b820 100644 --- a/README.md +++ b/README.md @@ -195,7 +195,7 @@ const escapeRegExp = str => str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); ### Even or odd number -Checks whether number is odd or even using the modulo (`%`) operator. +Checks whether a number is odd or even using the modulo (`%`) operator. Returns `true` if the number is even, `false` if the number is odd. ```js