Sheffield|May-2025|Sheida Shabankari|Module-Structuring-and-Testing-Data | Sprint-1#504
Sheffield|May-2025|Sheida Shabankari|Module-Structuring-and-Testing-Data | Sprint-1#504sheida-shab wants to merge 18 commits intoCodeYourFuture:mainfrom
Conversation
Create sprint-1
Describe what line 3 is doing
Show the first character of each string
the dir and ext part of the filePath variable
logging the value of num
add // to comment the text
change const to let for assigning
change the order of commands
updating the expression last4Digits is assigned to
varriable names must not start whit digits
percentageChange error handling
Testing and interpreting time format
Interpreting codes to-pounds
working with Chrome console
using objects and methods
updating the answers
cjyuan
left a comment
There was a problem hiding this comment.
Code and explanation are good.
I only have a few suggestions and comments.
|
|
||
| // 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 | ||
| Add 1 to the value of count variable and assign new the value to count variable |
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?
There was a problem hiding this comment.
yes, we can use count++ instead of count = count + 1
There was a problem hiding this comment.
There is a programming term (a single word) describing operation like count++ or count = count + 1.
What is the English term for this? Using proper terminology can help you communicate more effectively with other programmers.
| const num2 = Math.random() * (maximum - minimum + 1) | ||
| //third operation: floor() function round a number down to the nearest whole integer | ||
| const num3=Math.floor(num2) | ||
| //final operation : add the value of minimum var (1) to num3 and num4 is equal to num our result |
There was a problem hiding this comment.
Your current description is a literal translation of the JS code. Could you explain the purpose of adding minimum to num3?
There was a problem hiding this comment.
Of course ,I keep the result of "Math.floor(Math.random() * (maximum - minimum + 1))" in num3
and the main expression is "num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum;" that means I should add minimum to num3 value to get num value.
num = Math.floor(Math.random() * (maximum - minimum + 1)) + minimum
"num" is equal to "num4" is equal to "num3 + minimum"
There was a problem hiding this comment.
Sorry, I meant to ask, can you explain the purpose of adding minimum to Math.floor(Math.random() * (maximum - minimum + 1)) in the original expression?
For examples,
maximum - minimum + 1(which evaluates to 100) represents the range of the numbers we want to generate.Math.random() * (maximum - minimum + 1)is to scale the random number from the interval [0, 1) to [0, 100).
There was a problem hiding this comment.
The purpose of adding minimum is that we eant the result be greater than 1 because the value of minimum variable is 1.
There was a problem hiding this comment.
Or we can say, to "shift the range by 1", or "shift the range from [0, 99] to [1, 100]".
|
|
||
| // a) How many function calls are there in this file? Write down all the lines where a function call is made | ||
|
|
||
| 4 times : 2 times function Number() and 2 times function replaceAll() are called. |
There was a problem hiding this comment.
There are more than 4 function calls.
There was a problem hiding this comment.
Thank you . There are 5 functions.
Now I know that console.log() is a function too.I think it is a method and it's diffrent with function .
There was a problem hiding this comment.
You are right that method and function are not the same things.
In JavaScript, a method is a function that is associated with a property of an object.
That is why console.log() is also normally considered as a function call.
|
Your changes look good. I only have few follow-up questions/comments in the previous inline comment threads. |
|
Good job. |
No description provided.