native-javascript icon indicating copy to clipboard operation
native-javascript copied to clipboard

Add simple example of isNaN()

Open ManuelOviedo opened this issue 6 years ago • 4 comments

#31

ManuelOviedo avatar Oct 10 '19 13:10 ManuelOviedo

Hello @ManuelOviedo , We need native implementation of isNan function.

There's no prototype of isNaN. That property comes from ECMAScript convention for evaluate if a given value is NaN, if you get to the MDN links there are some links to its own ECMAScript related articles. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NaN https://tc39.es/ecma262/#sec-value-properties-of-the-global-object-nan

ManuelOviedo avatar Oct 10 '19 17:10 ManuelOviedo

Can you write a program which simple take a string as an input and check if its a number or not. If it's a number return false, else return true. @ManuelOviedo

TheSTL avatar Oct 10 '19 17:10 TheSTL

Can you write a program which simple take a string as an input and check if its a number or not. If it's a number return false, else return true. @ManuelOviedo

I think you missunderstood the purpose of that function. isNaN checks for a value if it's NOT a number and i guess my example is way too clear:

Number.prototype.isNaN = function(testValue){ return isNaN(testValue); }; the above example (same as PR) receives a value and evaluates it with isNaN function and will return true if it's not a number or false if it's a number

ManuelOviedo avatar Oct 10 '19 17:10 ManuelOviedo

Implementation should be done without using in-build functions or specifically don't use isNaN function, or parseInt type of functions

TheSTL avatar Oct 10 '19 17:10 TheSTL