Christiaan Erkelens - 1 year ago 59

Javascript Question

My code was working fine till I added the if statement. Any help is much appreciated.

`function calc() {`

var a = parseInt(document.getElementById('eersteGetal').value);

var b = parseInt(document.getElementById('tweedeGetal').value);

var answer = parseInt(a + b);

var quotient = a % b;

var bigger = '';

if(a >= b) {

bigger = "Number A is bigger";

} else if(a <= b) {

bigger = "Number B is bigger";

} else(a === b) {

bigger = "Number A en B are equal";

}

var paragraaf = document.getElementById('answer');

paragraaf.innerHTML = answer;

var paragraafTwo = document.getElementById('quotient');

paragraafTwo.innerHTML = quotient;

var paragraafThree = document.getElementById('bigger');

paragraafThree.innerHTML = bigger;

}

Recommended for you: Get network issues from **WhatsUp Gold**. **Not end users.**

Answer Source

You cant put a condition in an ELSE.

Change your IF/ELSE-STATEMENT to this:

```
if(a > b ) {
bigger = "Number A is bigger";
}
else if(a < b) {
bigger = "Number B is bigger";
}
else {
bigger = "Number A en B are equal";
}
```

Recommended from our users: **Dynamic Network Monitoring from WhatsUp Gold from IPSwitch**. ** Free Download**