Skip to content

Commit 51a63b1

Browse files
committed
docs: update README with prompt return values and console logs
1 parent bdd3224 commit 51a63b1

File tree

1 file changed

+48
-3
lines changed

1 file changed

+48
-3
lines changed

Sprint-1/4-stretch-explore/chrome.md

Lines changed: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ What effect does calling the `alert` function have?
2929
Now try invoking the function `prompt` with a string input of `"What is your name?"` - store the return value of your call to `prompt` in an variable called `myName`.
3030

3131

32-
let myName = prompt("hello what is your name")
33-
alert("hi " + myName)
32+
let myName = prompt("What is your name");
33+
alert("hi " + myName);
3434

35-
The prompt function displays a modal dialog that captures user input. The value entered is stored in myName, and alert then displays a greeting that includes that value.
35+
The prompt function displays a modal dialog that captures user input. The value entered is stored in myName, and alert then displays a greeting that includes that value input captured by the variable myName.
3636

3737

3838
What effect does calling the `prompt` function have?
@@ -48,3 +48,48 @@ What is the return value of `prompt`?
4848

4949
* Blocks interaction with the page until the user responds
5050

51+
If the user types something and clicks OK: It returns a String containing their text.
52+
53+
If the user clicks OK without typing: It returns an empty string ("").
54+
55+
If the user clicks Cancel or hits Esc: It returns null.
56+
57+
58+
59+
60+
# --- Browser Console Simulation ---
61+
62+
> alert("hi " + myName);
63+
64+
< undefined
65+
66+
> let myName = prompt("What is your name")
67+
68+
< undefined
69+
70+
> console.log(myName)
71+
72+
< null // User clicked Cancel
73+
74+
> let myName = prompt("What is your name")
75+
> console.log(myName)
76+
77+
< "Kyle" // User typed a name
78+
79+
> let myName = prompt("What is your name")
80+
> console.log(myName)
81+
82+
< "" // User clicked OK without typing
83+
84+
> console.log(typeof(myName))
85+
86+
< "string"
87+
88+
> console.log("Longitud:", myName.length);
89+
90+
< Longitud: 0
91+
92+
93+
94+
95+

0 commit comments

Comments
 (0)