I have the following statement where I just want to validate that user does not leave fields empty. My problem is at productPrice, if I uncomment those three lines, it will not work and get into else block even if the number I provide meets the criteria. If I leave it so only with productPrice != "" it will allow any string as value for price into the database. What is wrong here?
if (
productTitle != "" &&
productPrice != "" &&
// Number.isInteger(productPrice) &&
// productPrice > 0 &&
// productPrice < 1000 &&
productDescription != ""
) {
let productData = {
title: productTitle,
price: productPrice,
description: productDescription,
};
// .....
} else {
console.log("All fields required");
}
productPrice != "" &&and use the rest of the commented conditions.