-
-
Notifications
You must be signed in to change notification settings - Fork 50
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
NW6 | HAYTHEM MOHAMMED | Module-JS1 | WEEK1 #129
base: main
Are you sure you want to change the base?
Conversation
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.
Great work Haytham. I just wondered why you used the function Math.trunc instead of Math.floor. could you please tell me what's the difference between them :)
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.
Thanks, Fidaa for your feedback. And regarding your query about using Math.trunc instead of Math.floor! I would like to clarify that in this case, they are doing the same job. but in different cases, they return different values.
Math.trunc always removes any fractional digits. but Math.floor rounds down and returns the largest integer less than or equal to the given number. for example if we us both Math.trunc and Math.floor with "1.1" they will return the same result. but if we used them with "-1.1" the result will be different.
// It will help to think about the order in which expressions are evaluated | ||
// Try logging the value of num several times to build an idea of what the program is doing | ||
//The Program is to return a random integer between 1 and 100 | ||
|
||
console.log(num); |
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.
You have explained this very well. I found this a bit confusing to do myself but your explanation makes sense a lot. Well done!
What does the syntax `console.log` or `console.assert` mean? In particular, what does the `.` mean? | ||
// the console object is calling the functions log and assert. // The "." is to call a function. |
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.
This is a really good explanation. I did not know this. I think the whole group can benefit from this explanation.
@@ -27,3 +19,5 @@ console.log(`£${pounds}.${pence}`); | |||
// To begin, we can start with | |||
|
|||
// 1. const penceString = "399p": initialises a string variable with the value "399p" | |||
|
|||
// Substring, padStart and padEnd : to return part of string. |
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.
This is also very easy to understand and simple explanation. Good work!
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.
Your explanations are very clear and simple and easy to understand. Good work, well done!
const cardNumber = 4533787178994213; | ||
const last4Digits = cardNumber.slice(-4); | ||
const cardNumber = "4533787178994213"; | ||
const last4Digits = cardNumber.slice(12,16); |
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.
You can keep .slice(-4)
, that will still work. The only issue here was the string 🙂
@@ -15,4 +15,7 @@ const base = filePath.slice(lastSlashIndex + 1); | |||
console.log(`The base part of ${filePath} is ${base}`); | |||
|
|||
// Create a variable to store the dir part of the filePath variable | |||
const DirPart = filePath.slice(1, 45); |
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.
This solution works great for the example, but think about how we could extend the solution to work for different file paths (where we don't already know the length)
|
||
// b) How many function calls are there? | ||
// no function calls |
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.
console.log(..)
could be considered a function call 🙂
Learners, PR Template
Self checklist
Changelist
Briefly explain your PR.
Questions
Ask any questions you have for your reviewer.