JavaScript Question 22 (1 point) Assume userName equals “Tom” and userAge equals
ID: 3910451 • Letter: J
Question
JavaScript
Question 22 (1 point)
Assume userName equals “Tom” and userAge equals 22. What is displayed in a dialog box when the following statement is executed?
alert(userAge + " is " + userName + "'s age.");
22 is Tom's age.
22
is Tom's age.
22 is Tom's age.
22
is Tom's age.
uestion 23 (1 point)
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?
string data
integer data
numeric data
it is undefined
Question 24 (1 point)
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 would be returned if the user entered “fifteen” at the prompt?
You will be eligible to vote in undefined years
You will be eligible to vote in NaN years
You will be eligible to vote in years
nothing, the program would not run
Question 25 (1 point)
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 would be returned if the user entered 14.78 at the prompt?
You will be eligible to vote in 3 years
You will be eligible to vote in 4 years
You will be eligible to vote in 3.22 years
nothing, 14.78 is not an integer
Question 26 (1 point)
To write a string to a document, use
the write() or writeln() method
the prompt() method
the alert() method
all of these can be used
Save
Question 27 (1 point)
Which code would result in the same output as the following?
document.write("Welcome, my friend!<br>Glad you are here.");
document.writeln("<pre>Welcome, my friend!");
document.writeln("Glad you are here.</pre>");
document.writeln("<pre>Welcome, my friend! Glad you are here.</pre>");
document.writeln("Welcome, my friend!");
document.writeln("Glad you are here.");
document.writeln("<pre>Welcome, my friend!<br>Glad you are here.</pre>");
22 is Tom's age.
22
is Tom's age.
22 is Tom's age.
22
is Tom's age.
uestion 23 (1 point)
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?
string data
integer data
numeric data
it is undefined
Explanation / Answer
Question 22: 22 is Tom's age. Question 23: integer data Question 24: You will be eligible to vote in NaN years Question 25: You will be eligible to vote in 4 years Question 26: the write() or writeln() method Question 27: document.writeln("Welcome, my friend!");
Glad you are here.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.