prompts Flashcards

1
Q

What is the keyword that displays a box requesting user input?

A

prompt

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the keyword in a statement that shares most of the syntax of a prompt statement?

A

alert

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What do you need in order to capture a user’s input in a prompt box? Answer with one word.

A

variable

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q
var gender = prompt(askGender, bestGuess);
In the above statement, what is optional?
A

bestGuess

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Code a prompt with the message “Enter first name”. The user’s response is assigned to firstName, which hasn’t been declared beforehand.

A

var firstName = prompt(“Enter first name”);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Code a prompt with the message “Country?” and the default answer “China”. The user’s response is assigned to country, which hasn’t been declared beforehand.

A

var country = prompt(“Country?”, “China”);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Code a prompt that specifies a string as the message. Assign the user’s response to a variable that hasn’t been declared beforehand.

A

var parrotName = prompt(“Enter name of parrot”)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Code a prompt that specifies a string as the message. Include a default input. Assign the user’s response to a variable that hasn’t been declared beforehand.

A

var name = prompt(“Enter parrot name”, “Polly”);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Code a prompt that specifies a variable as the message and assigns the user’s response to a variable that hasn’t been declared beforehand.

A

var response = prompt(question);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Code a prompt that specifies a variable as the message, a second variable as the default response, and assigns the user’s response to a third variable that hasn’t been declared beforehand.

A

var response = prompt(question, defAnsw);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Assign strings to two variables. Code a prompt specifying the first variable as the message and the second variable as the default response. Assign the user’s response to a third variable. None of the variables have been declared beforehand.

A
var question = "Name of parrot?";
var defaultAnswer = "Polly";
var pName = prompt(question, defaultAnswer);
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q
var sex = prompt(askGender, bestGuess);
Re-code the statement above, omitting what's optional.
A

var sex = prompt(askGender);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly