If you use async your code becomes a bit more natural:
asyncfunctiondivide(numerator,denominator){if(typeofnumerator!=="number"){thrownewTypeError(`numerator should be a number in divide(${numerator}, ${denominator})`);}if(typeofdenominator!=="number"){thrownewTypeError(`denominator should be a number in divide(${numerator}, ${denominator})`);}if(0===denominator){thrownewError(`denominator should not be zero in divide(${numerator}, ${denominator})`);}returnnumerator/denominator;});
This however indicates that it would be probably be smart to remove the async and move that to a separate function. That would allow you to use the divide function in more scenario's.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
If you use
async
your code becomes a bit more natural:This however indicates that it would be probably be smart to remove the
async
and move that to a separate function. That would allow you to use thedivide
function in more scenario's.