You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Sprint-1/explore/chrome.md
+32Lines changed: 32 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,9 +10,41 @@ Let's try an example.
10
10
In the Chrome console,
11
11
invoke the function `alert` with an input string of `"Hello world!"`;
12
12
13
+
To invoke an alert that lives in the engine v8; we need to
14
+
run `alert("Hi there!")`
15
+
16
+
13
17
What effect does calling the `alert` function have?
14
18
19
+
In short: alert() interrupts the page to show a message and waits for the user to acknowledge it.
20
+
21
+
📢 The message you pass to alert() is displayed to the user.
22
+
23
+
⏸️ JavaScript execution pauses until the user clicks OK.
24
+
25
+
🚫 The user can’t interact with the page while the alert is open (it blocks the UI).
26
+
27
+
28
+
15
29
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`.
16
30
31
+
32
+
let myName = prompt("hello what is your name")
33
+
alert("hi " + myName)
34
+
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.
36
+
37
+
17
38
What effect does calling the `prompt` function have?
18
39
What is the return value of `prompt`?
40
+
41
+
Calling the prompt() function displays a modal pop-up dialog that:
42
+
43
+
* Shows a message to the user
44
+
45
+
* Includes a text input field
46
+
47
+
* Has OK and Cancel buttons
48
+
49
+
* Blocks interaction with the page until the user responds
0 commit comments