Skip to content

Commit 8d61f8c

Browse files
committed
chrome.md and objects.md committed
1 parent cf82eb5 commit 8d61f8c

2 files changed

Lines changed: 81 additions & 0 deletions

File tree

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

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,37 @@ Now try invoking the function `prompt` with a string input of `"What is your nam
1616

1717
What effect does calling the `prompt` function have?
1818
What is the return value of `prompt`?
19+
20+
Response:
21+
22+
1. Call the alert function
23+
In the console, typing 'alert("Hello world!");'
24+
25+
Effect:
26+
A small pop-up dialog box appears in the browser window with the message "Hello world!" and an OK button. The dialog is modal, so it blocks interaction with the web page until you click OK.
27+
28+
2. Call the prompt function typing:
29+
30+
let myName = prompt("What is your name?");
31+
32+
Effect:
33+
Another pop-up appears, this time with the message "What is your name?", a text input field, and OK/Cancel buttons.
34+
35+
When typed something and press OK, the string typed is returned and stored in the variable myName.
36+
If pressed Cancel or close the dialog without entering anything, the return value is null.
37+
38+
3. Check the return value
39+
After entering a name (e.g., "Carlos") and clicking OK, you can check:
40+
41+
console.log(myName);
42+
Output in the console:
43+
44+
Carlos
45+
46+
In summary:
47+
alert() displays a message and returns nothing (undefined).
48+
prompt() displays a message with an input field and returns either of one value:
49+
50+
The input string (if OK is clicked)
51+
null (if Cancel is clicked or the dialog is closed without input)
52+

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

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,58 @@ Open the Chrome devtools Console, type in `console.log` and then hit enter
66

77
What output do you get?
88

9+
When you typed console.log in the Console and hit Enter, shows something like:
10+
11+
ƒ log() { [native code] }
12+
This shows that console.log is a function (indicated by the ƒ symbol) that's built into the browser (hence "[native code]").
13+
914
Now enter just `console` in the Console, what output do you get back?
1015

16+
When typed console in the Console, it displays an object that looks something like:
17+
18+
Console {debug: ƒ, error: ƒ, info: ƒ, log: ƒ, warn: ƒ, …}
19+
This shows that console is an object containing many methods.
20+
1121
Try also entering `typeof console`
1222

23+
Typing typeof console returns:
24+
25+
"object"
26+
This confirms that console is an object data type.
27+
28+
console stores a collection of methods and properties used for debugging and logging information in the browser. It's a built-in object that provides access to the browser's debugging console. It contains methods like:
29+
30+
log() - for general output
31+
32+
error() - for error messages
33+
34+
warn() - for warnings
35+
36+
info() - for informational messages
37+
38+
assert() - for conditional logging
39+
40+
table() - for displaying tabular data
41+
42+
clear() - for clearing the console
43+
44+
And many more
45+
1346
Answer the following questions:
1447

1548
What does `console` store?
1649
What does the syntax `console.log` or `console.assert` mean? In particular, what does the `.` mean?
50+
51+
The dot (.) is the member access operator (also called the property accessor) in JavaScript.
52+
53+
When it shows console.log:
54+
55+
console is the object
56+
57+
. means "access a property of this object"
58+
59+
log is a property of the console object (specifically a method, which is a function stored as a property)
60+
61+
So console.log means "access the log property of the console object." Since log is a function, we can then call it with parentheses: console.log("Hello").
62+
This dot notation is how JavaScript allows objects to contain related data and functionality, organizing code into logical groups.
63+

0 commit comments

Comments
 (0)