I'm writing a simple discount app with prompt input. The problem is in my ternary operator - it doesn't count the newPrice as well as show that input is invalid. Can you tell me what I'm doing wrong?
I if the input is wrong I want to assign newPrice to null and alert 'Invalid data'
My code:
const price = prompt('Please, enter the price:');
const discount = prompt('Please, enter the discount amount:');
const newPrice = ((9999999 > price > 0) && (99 > discount > 0)) ? (price - price * discount / 100) : (null, alert('Invalid data'));
console.log(newPrice)