From 6549c734c4044c3142c16334a76f683e6d9162ef Mon Sep 17 00:00:00 2001 From: Jatin Panjwani Date: Fri, 11 Oct 2019 13:03:02 +0530 Subject: [PATCH] Implemented isNaN with test cases --- implementations/isNaN.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 implementations/isNaN.js diff --git a/implementations/isNaN.js b/implementations/isNaN.js new file mode 100644 index 0000000..e4d9ca9 --- /dev/null +++ b/implementations/isNaN.js @@ -0,0 +1,14 @@ +/** + * + The isNaN() method checks if passed value is NaN + + MDN Link: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isNaN + */ + +Number.prototype.ownIsNaN = function ownIsNaN(value) { + let x = Number(value); + return x !== x; +} + +// test cases +// {},'',null,undefined,' ',NaN,Infinity,true,false,'Infinity',[],new Date(),new Date().toString() \ No newline at end of file