Manchester | 26-ITP-Jan | Farancis Dore Etonkie |Sprint 1 |Structuring and testing data#1211
Manchester | 26-ITP-Jan | Farancis Dore Etonkie |Sprint 1 |Structuring and testing data#1211FarancisGH wants to merge 4 commits intoCodeYourFuture:mainfrom
Conversation
cjyuan
left a comment
There was a problem hiding this comment.
I noticed some inconsistent spacing in the code.
Have you installed the prettier VSCode extension and enabled "Format on save/paste" on VSCode, as recommended in
https://github.com/CodeYourFuture/Module-Structuring-and-Testing-Data/blob/main/readme.md
?
|
|
||
| // 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 | ||
| //This means that increase the count number by 1 (by adding 1 to the initial number) and maintain the count value after adding 1. E.g 0+1 =1, so the new count now will be 1. No newline at end of file |
There was a problem hiding this comment.
Operation like count = count + 1 is very common in programming, and there is a programming term describing such operation.
Can you find out what one-word programming term describes the operation on line 3?
|
|
||
| //This const minimum = 1; and this const maximum = 100; represent the range from which i want my random numbers to come from. | ||
|
|
||
| //This command Math.random() generates a random decimal number from 0(being inclusive) to 1(but not inclusing 1) e.g 0.23, 0.87, 0.001 or 0.999 but it will never generate 1. |
There was a problem hiding this comment.
Note:
We can also use the concise and precise interval notation to describe a range of values.
[,]=> inclusion(,)=> exclusion
For example, we can say Math.random() generates a random decimal number in [0, 1).
| const cardNumber = 4533787178994213; | ||
| const cardNumber = "4533787178994213"; | ||
| const last4Digits = cardNumber.slice(-4); |
There was a problem hiding this comment.
Suppose you were not allowed to modify the statement const cardNumber = 4533787178994213;
(that is, keep the variable's value unchanged).
How would you modify the code (through type conversion) so that you can still use .slice(-4) to extract the last 4 digits from the given number.
|
|
||
| // e) What do you think the variable result represents? Can you think of a better name for this variable? | ||
| // It creates a formated string. for example: 2:30:23. That is the movie duration formated in Hours:Minutes:Seconds. | ||
| //Better names could be; FormatedDuration or MovieDuration or FormatedTime. |
There was a problem hiding this comment.
All names look good.
Please note that in JS naming convention, variable names usually begins with a lowercase letter. Names starting with an uppercase letter are used for built-in and custom data types (e.g., Math)
Learners, PR Template
Self checklist
Changelist