JavaScript is a weakly typed language. Therefore, you must be careful with the types of data you use. Without knowing about your program, this can be fixed as follows:
alert(parseInt(ex1, 10) + parseInt(ex2, 10));
This ensures that both ex1and ex2are integers. If you think you will use floating point numbers
alert(parseFloat(ex1) + parseFloat(ex2));