How to operate in Jacascript alert

How to operate in Jacascript alert?


<h2>Seeking a combination of two numbers<h2>

<form name='form' id='form'>
  <input type='number' name='name' id='variable1' /> 
  <input type='number' name='email' id='variable2' />
  <input type='button' value='Go' data-action="submit"/>


const submitBtn = document.querySelector('[data-action="submit"]');
submitBtn.addEventListener("click", processFormData);

function processFormData(e) {

   const nameElement = document.getElementById("variable1");
   let name = nameElement.value;
   const emailElement = document.getElementById("variable2");
   let email = emailElement.value;

  alert((name + email));


I hope I can get two numbers on the front end and print them out.

I’m not sure - I’m looking at this right now on my project – but maybe having the “type” as number for input is throwing things off b/c the input should be a name and email.

Not really understanding your project. You have specified both the name and email inputs to be numbers. If they are supposed to be name and email, why would they be numbers.

Anyway, if you really want them to be numbers and are trying to add them together to display in the alert, you will need to convert them from strings to numbers. All values which come from form inputs are strings. The type=“number” is just for validation on the form and has nothing to do with any JavaScript which interacts with this data.

The following lines are where you would need to convert the values from the elements to numbers. You have learned how to do this in the Basic JavaScript section.

let name = nameElement.value;
let email = emailElement.value;

On a side note, you will need to prevent the default action of the form submitting by use the preventDefault method. Use Google to learn more about this method.