NAN error message

You must select a tag to post in this category. Please find the tag relating to the section of the course you are on E.g. loops, learn-compatibility

im dealing with the iteration and function section and was playing around with some different ways to code my function ( expression arrows etc. )

i came across this error message when trying t code the function can someone tell me why it is showing me this? although when coding it with arrow function method it works !

const smallerNums = => num - 5);


Error message I get :slight_smile:
return - 5 );

TypeError: NaN is not a function
at (native)
at smallerNums (/home/ccuser/workspace/javascript-iterators-choose-iterator/main.js:22:15)
at Object. (/home/ccuser/workspace/javascript-iterators-choose-iterator/main.js:25:1)
at Module._compile (module.js:571:32)
at Object.Module._extensions…js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.runMain (module.js:605:10)
at run (bootstrap_node.js:427:7)

I just tried this with a random array of numbers in ‘nums’ and it works fine. Seems likely that your nums array is perhaps the wrong type and isn’t being coerced?

Can you post your full code? Use the preformatted tag to preserve the readability too (the </> symbol on the toolbar).


An array’s map function takes another function. For what arguments will be passed into this function see: - JavaScript | MDN. num - 5 must be returning NaN, hence why map is trying to use NaN as a function.

1 Like