0

I'm beginner at JavaScript and I need some help with this. Let's say a user has to enter a number from the HTML form. Then in another function there is a calculation, but when I'm calling the other function I'm getting NaN. This is my function when I'm entering the number, and if I output this I'm getting the calculated result.

const enterNumbers = number => {

    if (number < 10000) {
        return 0.062 * number;
    } else {
        return 0.062 * 20000;
    }

If I output this in a third function let's say

const display = () => {
    console.log (enterNumbers((number)));

I'm getting the result, but then in another function I want to make some calculation with the number calculated from the enterNumbers function

const calculation = () => {
    return enterNumbers * 10;
}

and then when I call the second function in the display function I'm getting a NaN.


Heretic Monkey
  • 11,687
  • 7
  • 53
  • 122
  • The variable `enterNumbers` appears to be a function definition. You are trying to multiply a function definition by 10, which is NaN. – James Feb 17 '22 at 18:34

1 Answers1

0

What happens if you call?

const calculation = () => {
   return enterNumbers(<ANY_NUMBER_HERE>) * 10;
}
Breno Prata
  • 712
  • 5
  • 10