File tree Expand file tree Collapse file tree 1 file changed +67
-0
lines changed
Sprint-1/4-stretch-explore Expand file tree Collapse file tree 1 file changed +67
-0
lines changed Original file line number Diff line number Diff line change @@ -16,3 +16,70 @@ Now try invoking the function `prompt` with a string input of `"What is your nam
1616
1717What effect does calling the ` prompt ` function have?
1818What is the return value of ` prompt ` ?
19+
20+ 1 . The alert() function
21+
22+ Code:
23+
24+ alert("Hello world!");
25+
26+ Effect:
27+
28+ When you call alert("Hello world!") in the Chrome Console:
29+
30+ A modal dialog box (popup window) appears on the screen.
31+
32+ It displays the message:
33+
34+ Hello world!
35+
36+ The dialog has an “OK” button that you must click before continuing.
37+
38+ Purpose:
39+ It’s used to display information to the user — a simple way to show messages or debugging output in the browser.
40+
41+ Return value:
42+
43+ alert() does not return any value — its return value is undefined.
44+
45+ 2 . The prompt() function
46+
47+ Code:
48+
49+ let myName = prompt("What is your name?");
50+
51+ Effect:
52+
53+ When you call this:
54+
55+ A popup dialog appears with:
56+
57+ A message: "What is your name?"
58+
59+ A text input box
60+
61+ “OK” and “Cancel” buttons.
62+
63+ The user can type something (e.g., Alice) and click “OK” or “Cancel”.
64+
65+ Return value:
66+
67+ If the user types something (e.g., "Alice") and clicks OK
68+ prompt() returns the string "Alice".
69+
70+ If the user clicks Cancel
71+ prompt() returns null.
72+
73+ So after running:
74+
75+ let myName = prompt("What is your name?");
76+
77+ You’ll have:
78+
79+ myName === "Alice" (if entered “Alice”)
80+
81+ myName === null (if Cancelled)
82+
83+ Purpose:
84+ prompt() is used to get text input from the user through a browser dialog.
85+
You can’t perform that action at this time.
0 commit comments