content icon indicating copy to clipboard operation
content copied to clipboard

Wrong use of `isNaN()`.

Open Amer-Adel opened this issue 1 year ago • 3 comments

MDN URL

https://developer.mozilla.org/en-US/docs/Learn/JavaScript/First_steps/Test_your_skills:_Math

What specific section or headline is this issue about?

Math 2

What information was incorrect, unhelpful, or incomplete?

const finalNumberCheck = isNaN(finalNumber) === false ? 'finalNumber is a number type. Well done!' : `Ooops! finalNumber is not a number.`;

What did you expect to see?

is NaN Return value true if the given value is NaN after being converted to a number; otherwise, false.

And because we shouldn't convert the value '4633.33' to number ourselves instead of the learner, we could use typeof `

const finalNumberCheck = typeof finalNumber === "number" ? 'finalNumber is a number type. Well done!' : `Ooops! finalNumber is not a number.`;

Do you have any supporting links, references, or citations?

No response

Do you have anything more you want to share?

No response

MDN metadata

Page report details
  • Folder: en-us/learn/javascript/first_steps/test_your_skills_colon__math
  • MDN URL: https://developer.mozilla.org/en-US/docs/Learn/JavaScript/First_steps/Test_your_skills:_Math
  • GitHub URL: https://github.com/mdn/content/blob/main/files/en-us/learn/javascript/first_steps/test_your_skills_colon__math/index.md
  • Last commit: https://github.com/mdn/content/commit/60358aa4fdd02bda2573dfd9fdf038b4ead2cd06
  • Document last modified: 2024-02-02T19:50:32.000Z

Amer-Adel avatar Feb 10 '24 21:02 Amer-Adel

Accepting a PR to change isNaN(finalNumber) to typeof finalNumber === "number"

Josh-Cena avatar Jun 05 '24 08:06 Josh-Cena

@Josh-Cena can you assign me to this

monyasau avatar Jun 28 '24 16:06 monyasau

You just need to send a PR. No need to ask for assignment.

Josh-Cena avatar Jun 28 '24 16:06 Josh-Cena