Trying to make a function that works when the checkbox is checked


#1
<div id="dolny">
<h2>Ile będzie kosztowało moje wesele?</h2>
<label for="a">Podaj liczbę gości:</label> <input type="number" id="lgosci"> <br>
<label for="a">Wesele z poprawinami?</label><input type="checkbox" id="poprawiny"> <br>
<input type="button" id="przycisk" onclick="suma()" value="Oblicz koszt">
</br>
<p>
<div id="koszt"></div>
</p>
</div>
<script type="text/javascript">

function suma(){

var a = document.getElementById("lgosci").value;
var b = document.getElementById("poprawiny");

If(b.checked){
	var cena = a * 100
	document.getElementById("koszt").innerHTML = cena;
}

}

</script>

I’m quite new to all this and I’m pretty confused right now.


#2

as stupid as it sounds, the answer to your problem is don’t capitalize the if.