-
-
Notifications
You must be signed in to change notification settings - Fork 237
Manchester | 25-ITP-May | Fithi Teklom| Sprint 1 | Coursework Sprint 1 #771
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?
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.
Looking really good! Some additional questions to test & challenge your understanding 🙂
// Try logging the value of num and running the program several times to build an idea of what the program is doing | ||
console.log(num); | ||
|
||
// num is a random integer between minimum and maximum, including both endpoints. |
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 is the difference between an integer and decimal number?
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.
Integer is a whole number(no fraction and no decimal). But Decimal number is a number with a ( . ), that can be fractional or decimal.
// Read the code and then answer the questions below | ||
|
||
// a) How many function calls are there in this file? Write down all the lines where a function call is made | ||
// There are 5 function calls. Number(), carPrice.replaceAll(),priceAfterOneYear.replaceAll(), console.log(),percentageChange(), |
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.
Is percentageChange()
a function here?
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.
No, but there are 2 Number functions. I have updated it in the exercise.
//const percentageChange = (priceDifference / carPrice) * 100; | ||
|
||
// e) Describe what the expression Number(carPrice.replaceAll(",","")) is doing - what is the purpose of this expression? | ||
// It replaces the number to a clean 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.
Could you explain a bit more what you mean here?
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.
I meant a string without unnecessary spaces, comma or underscore. Just the string as it is.
|
||
// c) Using documentation, explain what the expression movieLength % 60 represents | ||
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators | ||
//Remainder assignment. Which means when 8784 seconds is divided by 60 it gives 24. |
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.
Could you clarify this?
8784
divided by 60
gives 146.4
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.
I meant it gives a remainder value which is 24. So when 8784 is divided by 60 it gives 146 and a remainder of 24.
//Dividing that by 60 converts the remaining seconds into whole minutes. | ||
|
||
// e) What do you think the variable result represents? Can you think of a better name for this variable? | ||
//It represents movie duration. A better name can be formattedMovie. |
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.
Is there another variable name you could use here that gives even more context?
//It represents movie duration. A better name can be formattedMovie. | ||
|
||
// f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer | ||
// Mostly yes, but not good for fractional values, negative numbers and numbers less than 0, the leading 0 may not be displayed. |
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.
These are really good edge cases!
I've just noticed you're missing exercise 3, could you also include this 🙂 |
Self checklist