London | 25-ITP-Sep | KME Blair | Sprint 1 | Coursework#828
London | 25-ITP-Sep | KME Blair | Sprint 1 | Coursework#828kohanman wants to merge 13 commits intoCodeYourFuture:mainfrom
Conversation
| // The = operator is used to assign the new count variable as the original count + 1. | ||
| // testing commit 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?
|
|
||
| let initials = ``; | ||
| let initials = firstName.slice(0, 1)+middleName.slice(0, 1)+lastName.slice(0, 1); |
There was a problem hiding this comment.
There is a shorter syntax to refer to the first character in a string.
|
|
||
| console.log(num); | ||
|
|
||
| //Math.random generates a decimal number between 0 and 1 |
There was a problem hiding this comment.
Phrases like "a number between X and Y" are not precise enough in a program specification, because they do not clearly state whether the endpoints X and Y are included.
We can use the concise and precise interval notation to describe a range of values.
[,]=> inclusion(,)=> exclusion
If we want to denote "x in the range 1 < x <= 100", we can say x is in the interval (1, 100].
Can you use this notation to describe the returned value of Math.random()?
| // so total 5 function calls | ||
|
|
||
| // 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? | ||
| // error is in line 5, because of a missing , in replaceAll("," ""), which I will add to fix the problem. |
There was a problem hiding this comment.
In the function call .replaceAll(",", ""), there's a programming term for "," and "" (the values passed into the function).
Could you find out what they are called so that you can more precisely indicate where the , is missing.
Learners, PR Template
Self checklist
Changelist
Completed all the coursework exercises in Sprint 1 of Module Structuring and Testing Data
Questions
no questions atm