Javascript addition example

This example creates two variables using the var statement. The Number function converts the character strings the user enters into the n1 and n2 textboxes to numbers. The assignment statement adds them and assigns their sum to the value property of the textbox called n3, causing it to be displayed.

 

First number:  

Second number:  

Their sum:  


Disclaimer: The views and opinions expressed on unofficial pages of California State University, Dominguez Hills faculty, staff or students are strictly those of the page authors. The content of these pages has not been reviewed or approved by California State University, Dominguez Hills.