parseInt
doesn't return 0 when I use it in the function below :
const getGuestsCount = guestsInput => {
if (parseInt(guestsInput)) {
return parseInt(guestsInput);
}
return 'not a number';
};
For example, getGuestsCount('0 we won\'t visit you!!');
returns "not a number"
But if we use parseInt
outside of the function then it's ok,
parseInt('0 we won\'t visit you!!');
returns 0 as expected