Code Example 2-1 1. var myAge, newAge; 2. myAge = prompt("How old are you?"); 3. myAge = parseInt(myAge); 4. newAge = 18 - myAge; 5. alert("You will be eligible to vote in " + newAge + " years"); (Refer to Code Example 2-1) What type of data is stored in myAge after line 2 is executed?

Respuesta :

Answer: String Data

Explanation: In Javascript, the  prompt() method is used to display a dialog that prompts you to insert an optional message which is basically some text.

The text can be  textual, numerical (as in your example) or both but all this line of the program (line 2) is trying to do is to get data from the user.

It returns a STRING containing the text entered by the user, or null.

Note: The string that is returned cannot be used directly to solve any math until you convert it to an integer. That's what line 3 is for.

ACCESS MORE
EDU ACCESS