JavaScript – If Else If

If-else-if ladder: 

  • It is allowed to defined multiple if blocks sequentially.
  • Itexecutes only one block among the multiple blocks defined.

Program to check biggest among two numbers:

                                    function big(){
                                                var a = parseInt(document.getElementById(“first”).value);
                                                var b = parseInt(document.getElementById(“second”).value);
                                                var c = parseInt(document.getElementById(“third”).value);
                                                if(a>b && a>c)
                                                            document.write(“a is big”);
                                                            document.write(“b is big”);
                                                            document.write(“c is big”);
                        First Number : <input type=”text” id=”first”/>br/>
                        Second Number : <input type=”text” id=”second”/><br/>
                        Third Number : <input type=”text” id=”third”/>br/>
                        <button onclick=”big()”> Biggest of 3 </button>
Scroll to Top