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
// b) Run the code and identify the line where the error is coming from - why is this error occurring? How can you fix this problem?
17
-
17
+
// The error is occurring on line 5 because there is a missing comma in the replaceAll method. The correct syntax should be replaceAll(",", "").
18
18
// c) Identify all the lines that are variable reassignment statements
19
-
19
+
// 2 variable reassignment statements: line 4 and line 5
20
20
// d) Identify all the lines that are variable declarations
21
-
21
+
// 4 variable declarations: line 1, line 2, line 7, line 8
22
22
// e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression?
23
+
// The expression Number(carPrice.replaceAll(",", "")) is first using the replaceAll method to remove all commas from the carPrice string, resulting in a string that represents a number without any formatting. Then, the Number function is used to convert that string into a numeric value. The purpose of this expression is to convert the formatted string representation of the car price into a usable numeric value for calculations.
// The expression movieLength % 60 calculates the remainder of the division of movieLength by 60, which gives the number of seconds remaining after converting the total length of the movie from seconds to minutes.
20
21
21
22
// d) Interpret line 4, what does the expression assigned to totalMinutes mean?
22
-
23
+
// line 4 calculates the total number of minutes in the movie by subtracting the remaining seconds from the total movie length in seconds and then dividing that value by 60, thus converting the total length of the movie from seconds to minutes.
23
24
// e) What do you think the variable result represents? Can you think of a better name for this variable?
24
-
25
+
// The variable result represents the total length of the movie in hours, minutes, and seconds format. A better name for this variable could be movieDuration or formattedMovieLength, as it more clearly describes the purpose of the variable.
25
26
// f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer
Copy file name to clipboardExpand all lines: Sprint-2/4-stretch-explore/chrome.md
+3-1Lines changed: 3 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,8 +8,10 @@ Let's try an example.
8
8
In the Chrome console, invoke the function `alert` with one argument, the string `"Hello world!"`;
9
9
10
10
What effect does calling the `alert` function have?
11
-
11
+
a pop-up box with a message of HELLO WORLD on the window
12
12
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`.
13
13
14
14
What effect does calling the `prompt` function have?
15
+
the effect propmt displayed on the window is a pop-up box with an empty field to fill and with the string on top of it and when a user filled the field in. The filled in value gets displayed on the console.
15
16
What is the return value of `prompt`?
17
+
// the return value of the prompt as explained above is the answer or the value the user puts in the prompted field on the window.
0 commit comments