0
I am developing a calculation that adds interest according to the number of installments, but it is returning the wrong amount.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Exercicio1</title>
<script>
function caculoCompra(total,parcelas){
var resul=0;
if(parcelas=1){
resul+=total*0
}
else if(parcelas=2){
resul+=(total*0.3)/100
}
else{
resul+=(total*0.7)/100
}
return resul;
}
window.onload = function(){
var btn = document.getElementById("btn");
btn.onclick = function (){
var resp;
var valor = document.getElementById("valor").value;
var parcelas = document.getElementById("parcelas").value;
resp=caculoCompra(valor,parcelas);
alert("O valor final é " + resp);
}
}
</script>
</head>
<body>
<h2>Exercicio 1</h2>
<form name="form1" id="form1" method="post" action="" >
Informe o valor
<input name="login" type="text" id="valor" size="15">
<br>
Informe o numero de parcelas
<input name="senha" type="text" id="parcelas" size="10">
<br>
<input type="button" name="button" id="btn" value="OK">
</form>
</body>
</html>
The value that is returning