-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathdescuentos.js
32 lines (22 loc) · 876 Bytes
/
descuentos.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// const precioOriginal = 120;
// const descuento = 18;
function calcularPrecioConDescuento(precio, descuento) {
const porcentajePrecioConDescuento = 100 - descuento;
const precioConDescuento = (precio * porcentajePrecioConDescuento) / 100;
return precioConDescuento;
}
function onClickButtonPriceDiscount() {
const inputPrice = document.getElementById("InputPrice");
const priceValue = inputPrice.value;
const inputDiscount = document.getElementById("InputDiscount");
const discountValue = inputDiscount.value;
const precioConDescuento = calcularPrecioConDescuento(priceValue, discountValue);
const resultP = document.getElementById("ResultP");
resultP.innerText = "El precio con descuento son: $" + precioConDescuento;
}
// console.log({
// precioOriginal,
// descuento,
// porcentajePrecioConDescuento,
// precioConDescuento,
// });