Skip to content

Commit

Permalink
se agrega algo de css y formato de monedas
Browse files Browse the repository at this point in the history
  • Loading branch information
santiagogak committed Nov 6, 2024
1 parent 3002cf7 commit 48acac5
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
9 changes: 9 additions & 0 deletions css/main.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}

body {
background-image: url('../img/dollar_background.jpg');
}
Binary file added img/dollar_background.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="css/main.css">
<title>Calculadora de Cuotas de Crédito</title>
</head>
<body>
Expand Down
11 changes: 7 additions & 4 deletions js/calcuotas.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ const pagoMensual = (cap, int, cuo) => {
}
};

//Funcion para dar formato de moneda al número
const formatoMoneda = (monto) => monto.toLocaleString('es-CL', {style: 'currency', currency: 'CLP', maximumFractionDigits: 2 });

//Función para calcular todos los pagos mensuales mes a mes y el interés que se paga en cada uno, así como el total de interes pagado
function detallePagos (cap, int, cuo) {
const intN = int / 100;
Expand All @@ -54,16 +57,16 @@ function detallePagos (cap, int, cuo) {
let totalInteres = 0;
for (let i = 1; i <= cuotas; i++) {
const capMes = restoCap * (1+intN);
strPagos = strPagos + `Pago ${i}: ${restoCap.toFixed(2)} - Interés: ${(restoCap*intN).toFixed(2)}\n`;
strPagos = strPagos + `Pago ${i}: ${formatoMoneda(restoCap)} - Interés: ${formatoMoneda(restoCap*intN)}\n`;
totalInteres += restoCap*intN;
restoCap = capMes - pagoMes;
}
strPagos = strPagos + `\nTotal Intereses: ${totalInteres.toFixed(2)}`;
strPagos = strPagos + `\nTotal Intereses: ${formatoMoneda(totalInteres)}`;
} else {
strPagos = strPagos + `Pago: ${cap} - Interés: 0`;
strPagos = strPagos + `Pago: ${formatoMoneda(cap)} - Interés: 0`;
}
return strPagos;
}

alert(`Pago Mensual: ${pagoMensual(capital,interes,cuotas).toFixed(2)}`)
alert(`Pago Mensual: ${formatoMoneda(pagoMensual(capital,interes,cuotas))}`)
alert(detallePagos(capital,interes,cuotas))

0 comments on commit 48acac5

Please sign in to comment.