-4

I am new to JavaScript, right now I'm just practicing in hope to get better. I have been given a task to use this form to take in 2 numbers and output the sum as an alert. I have tried looking around online but the way that this code is structured makes it difficult for me to understand how it is supposed to work. Can anyone assist me on this?

<form>
    <input id="x" size=3> + <input id="y" size=3>
    <input type=submit value=" = " onclick="calculate()">
</form> 
Francisco
  • 10,918
  • 6
  • 34
  • 45
User1264
  • 13
  • 4

1 Answers1

1

You need to create a function called calculate in JavaScript file or within a <script> tag which job is to do that.

The idea is to get the inputs elements with id x and y, read their value, add them together and display the result in a alert call.

Good luck with your homework :)

floribon
  • 19,175
  • 5
  • 54
  • 66