-
-
Notifications
You must be signed in to change notification settings - Fork 387
Birmingham | ITP-May26 | Ogbemi Mene | Sprint 1 | Coursework/sprint1 #1415
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
fa9f5e6
8b14301
b068348
1306b9c
fa09cac
74c5586
41d7543
1431ccf
6f4f1b7
2198c0b
a1593bb
ce41270
6842ec5
4fc7fc8
1b39660
9cb856a
c0e0589
6c9a6fa
25c9548
5bb384f
43833ef
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,13 @@ | ||
| let count = 0; | ||
|
|
||
| count = count + 1; | ||
| console.log(count); | ||
|
|
||
| // Line 1 is a variable declaration, creating the count variable with an initial value of 0 | ||
| // Describe what line 3 is doing, in particular focus on what = is doing | ||
|
|
||
| //Line 3 is updating the value of the variable `count`. | ||
| //The `=` operator is an assignment operator, | ||
| //which means it takes the value on the right side (in this case, `count + 1`, | ||
| //which evaluates to 1) and assigns it to the variable on the left side (`count`). | ||
| //So after this line executes, the value of `count` will be updated from 0 to 1. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,5 @@ | ||
| This is just an instruction for the first activity - but it is just for human consumption | ||
| We don't want the computer to run these 2 lines - how can we solve this problem? | ||
| We don't want the computer to run these 2 lines - how can we solve this problem? | ||
|
|
||
| //to answer this question, we can use comments in our code. | ||
| //In JavaScript, we can use `//` for single-line comments or `/* */` for multi-line comments. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,12 @@ | ||
| const 12HourClockTime = "8:53pm"; | ||
| const 24hourClockTime = "20:53"; | ||
|
|
||
| // The error in the code is that the variable `12HourClockTime` starts with a number, | ||
| // which is not allowed in JavaScript variable names. | ||
| // Variable names must start with a letter, underscore (_), or dollar sign ($). | ||
| // To fix this error, we can rename the variable to start with a letter, | ||
| // such as `twelveHourClockTime` or `hour12ClockTime`. | ||
| const twelveHourClockTime = "8:53pm"; | ||
| const hour24ClockTime = "20:53"; | ||
| // you can ether put the number at thr end of the variable name or spell it out in words, | ||
| // but you cannot start a variable name with a number. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,7 +12,12 @@ invoke the function `alert` with an input string of `"Hello world!"`; | |
|
|
||
| What effect does calling the `alert` function have? | ||
|
|
||
| The Effect: Calling alert pauses the browser execution and triggers a modal pop-up dialog box at the top of the screen displaying the text "Hello world!". It includes an "OK" button that the user must click to dismiss the alert and resume interacting with the page. | ||
|
|
||
| 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`. | ||
|
|
||
| What effect does calling the `prompt` function have? | ||
|
|
||
| The Effect: Calling prompt opens a different type of pop-up dialog box that displays the message "What is your name?", a text input field for the user to type into, and two buttons: "OK" and "Cancel". | ||
| What is the return value of `prompt`? | ||
| The Return Value: * If you type a name (e.g., "Alex") and click OK, the function returns that exact text as a string (undefind). This string is what gets stored in your myName variable. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What if a user types a name and then click Cancel instead of OK?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Even if the user types a full name into the text box, clicking Cancel overrides everything and tells the browser to discard the input. The function will completely ignore whatever text was typed and return null.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i did not make any change, i only gave response to the questions |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Operation like
count = count + 1is very common in programming, and there is a programming term describing such operation.Could you find out what one-word programming term describes the operation on line 3?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The one-word programming term that describes this operation is increment or incrementing)