-
-
Notifications
You must be signed in to change notification settings - Fork 545
Cape Town | 26-ITP-Sep | Yama Ngcanga | Sprint 2 | Coursework: Sprint 2 #1597
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
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 |
|---|---|---|
|
|
@@ -7,3 +7,8 @@ const num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum; | |
| // Try breaking down the expression and using documentation to explain what it means | ||
| // It will help to think about the order in which expressions are evaluated | ||
| // Try logging the value of num and running the program several times to build an idea of what the program is doing | ||
|
|
||
| Math.random() gives you a random decimal between 0 and just-under-1 — like 0.628.... | ||
| Then you multiply that by 100 (which is maximum - minimum + 1), stretching it out into a decimal between 0 and just-under-100. | ||
| Math.floor() chops off everything after the decimal point, rounding down, you've got a whole number from 0 to 99. | ||
| + minimum (which is +1) shifts the whole thing up by one, so instead of 0–99 you get 1–100. | ||
|
Comment on lines
+11
to
+14
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. Note: We could also use the concise and precise interval notation to describe a range of values.
For example,
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. Duly noted, thanks |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,4 @@ | ||
| 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? | ||
|
|
||
| by adding // infront of each line before writing a text/code |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,4 @@ | ||
| const 12HourClockTime = "8:53pm"; | ||
| const 24hourClockTime = "20:53"; | ||
|
|
||
| it'll throw a SyntaxError before anything executes, because both variable names start with a number. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,3 +20,9 @@ console.log(`The percentage change is ${percentageChange}`); | |
| // d) Identify all the lines that are variable declarations | ||
|
|
||
| // e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression? | ||
|
|
||
| a) 5 calls across 3 lines | ||
| b) error is on line 5, there's a missing comma between ',' and "" | ||
|
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. We could more precisely describe "A comma is missing between What is this programming term that refers to the values passed to a function? It begins with an 'a'.
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. If i'm understanding your question, it was a numbering system i used when answering the questions. |
||
| c)reassignments on line 4 and 5 | ||
| d) declarations on lines 1,2,7,8 | ||
| e) carPrice starts as the string "10,000" — you can't do maths on that as-is, the comma would mess things up. So first, .replaceAll(",", "") strips out the comma, leaving "10000". Then Number(...) converts that string into an actual number, 10000, that you can subtract and divide like normal. | ||
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.
What do the code
```javascriptand```on lines 14 and 16 do?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.
It was just to specify the language used in the code and where the code block starts and ends in markdown.