Manchester | 25-ITP-May | Fithi Teklom| Sprint 1 | Coursework Sprint 1#771
Manchester | 25-ITP-May | Fithi Teklom| Sprint 1 | Coursework Sprint 1#771Fithi-Teklom wants to merge 12 commits intoCodeYourFuture:mainfrom
Conversation
CameronDowner
left a comment
There was a problem hiding this comment.
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.
What is the difference between an integer and decimal number?
There was a problem hiding this comment.
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.
Is percentageChange() a function here?
There was a problem hiding this comment.
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.
Could you explain a bit more what you mean here?
There was a problem hiding this comment.
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.
Could you clarify this?
8784 divided by 60 gives 146.4
There was a problem hiding this comment.
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.
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. No newline at end of file |
There was a problem hiding this comment.
These are really good edge cases!
|
I've just noticed you're missing exercise 3, could you also include this 🙂 |
CameronDowner
left a comment
There was a problem hiding this comment.
Looking really good 🙂
I've left a comment on Sprint-1/4-stretch-explore/objects.md - but happy to mark as complete as this is a stretch goal. Any questions let me know
| Open the Chrome devtools Console, type in `console.log` and then hit enter | ||
|
|
||
| What output do you get? | ||
| // The 'console.log' as it is appears but with a single qoute. |

Self checklist