Skip to content

Commit

Permalink
added is_even.js
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielJDufour committed Nov 22, 2022
1 parent da9d862 commit 1c72a67
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions is_even.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const clean = require("./clean.js");
const is_integer = require("./is_integer.js");

function is_even(n) {
n = clean(n);

if (!is_integer(n)) throw new Error("can't call is_even on decimal");

return ["0", "2", "4", "6", "8"].includes(n.charAt(n.length - 1));
}

module.exports = is_even;
module.exports.default = is_even;

0 comments on commit 1c72a67

Please sign in to comment.