I am trying to make my program work, but something is wrong. I want to do a simple tax program, where I am calculating the total price including tax on X amount of items. I want to enter the values using prompt command in JavaScript. Here is my code:
let phonePrice;
let quantity;
let tax;
let total;
let total2;
phonePrice = prompt('Enter the phone price here...','');
quantity = prompt('Enter quantity here...','');
tax = phonePrice * 0.05;
total = phonePrice + tax;
total2 = quantity * total
alert('The Price on ' + quantity + ' phones with tax included is ' + total2 + ' dollars.');
Everything works fine until I want to add decimal number as value. Quantity can't be decimal number of course, but, for example, the item price can be 119.95 dollars. When I enter this number directly in ti the script (without prompt) everything is fine, but when i declare prompt and enter the same value in the browser, it give me NaN as value which is not a number. Anyone got any explanation, and how can I fix this?