London | 26-ITP-Sep | Chandaramani Gaire | Sprint 2 | Sprint 2 Coursework - #1605
gaireprakash20-ops wants to merge 35 commits into
Conversation
✅ Deploy Preview for cyf-onboarding-module ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
gaireprakash20-ops
left a comment
There was a problem hiding this comment.
i summit all the files with old commits and going to changes the last question thanks for your help and support abdi
d84d56d to
84b913c
Compare
| // Try logging the value of num and running the program several times to build an idea of what the program is doing | ||
|
|
||
| // In this exercise, num represent the value integer number between 1 to 100. | ||
| //Math.random generates a random decimal number from 0 up to 1, but not including, 1. |
There was a problem hiding this comment.
I think you got the right idea. Can you rephrase the sentences and include the code bits you are referring to. For example what part is doing the rounding?
| We don't want the computer to run these 2 lines - how can we solve this problem? No newline at end of file | ||
| /*This is just an instruction for the first activity - but it is just for human consumption | ||
| We don't want the computer to run these 2 lines - how can we solve this problem? | ||
| for single line we used // and for multiple line use */ No newline at end of file |
| console.log(`I was born in ${cityOfBirth}`); | ||
| const cityOfBirth = "Bolton"; | ||
|
|
||
| /*we need to put declare variables(const cityOfBirth = "Bolton";) in first line after using expression console.log*/ No newline at end of file |
There was a problem hiding this comment.
What do you mean with "after using expression console.log"?
There was a problem hiding this comment.
to print the output i try to write in a clear way
| // when i put capital letter ReferenceError: string is not defined so that nothing last4Digits not showed | ||
| //in the terminal String is the function but string is the normal text. No newline at end of file |
There was a problem hiding this comment.
I don't understand this sentence. Can you rephrase it please
There was a problem hiding this comment.
I change and clearly defined the capital S is the actual String function Lower s is just the text
|
|
||
| const result = `${totalHours}:${remainingMinutes}:${remainingSeconds}`; | ||
| console.log(result); | ||
| // |
There was a problem hiding this comment.
What is this line doing and is it needed?
There was a problem hiding this comment.
take out unwanted line
|
|
||
| // e) What do you think the variable result represents? Can you think of a better name for this variable? | ||
| /* The variable represent the movieLength in second,minutes and hours. | ||
| We can change this name as movieTime*/ |
There was a problem hiding this comment.
moveTime is better than result. It is still ambigious on what exactly it repsents. Another option for a variable name that is comen for strings is to use formatted as prefix. E.g. formattedMovieLength. This indicates that it is a formatted string
There was a problem hiding this comment.
yes i write formattedMovieLength
| /* In this section we can only use the positive natural numbers but if we put numbers that divide by 60 without a remainder get the exact time like 10, 20 50 */ | ||
| /*"Percent (%) is a way to describe the full amount of anything by imagining it split into 100 equal sections.*/ | ||
| /*we take out the odd seconds before converting to minutes so that when we divide by 60 we can get the exact whole number instead of messy decimal so that*/ | ||
| /* i try both decimal both terminal is not showing the error type looks prefect */ | ||
| /*[Running] node "c:\Users\Asus\Desktop\code your future\Module-Onboarding\Module-JavaScript-Fundamentals\Sprint-2\Sprint-2\3-mandatory-interpret\2-time-format.js" | ||
| 2:26:24 | ||
| /* In this case 60% is the remaining second after take out all minutes there has remain second is 24 */ No newline at end of file |
There was a problem hiding this comment.
I don't understand this comment. What do you mean with 10, 20 50? What do you need percentages for?
There was a problem hiding this comment.
I change the answer for f and gives the answer by checking the different numbers and strings for the different move length.
|
|
||
| // remove the p from the "399p" and make "399" | ||
| const paddedPenceNumberString = penceStringWithoutTrailingP.padStart(3, "0"); | ||
| //padStart() add characters to the starting of the string and provide 3 long characters. |
There was a problem hiding this comment.
What do you mean by provide 3 long characters? Which characters are added?
There was a problem hiding this comment.
String will be 3 characters "399" is not added showing 0 is add until string 3 char long
| 0, | ||
| paddedPenceNumberString.length - 2 | ||
| ); | ||
| // we take out the 2 character and store the remaining part of the string as the pound. |
There was a problem hiding this comment.
we saved the first index into pounds and remaining should be removed
| const pence = paddedPenceNumberString | ||
| .substring(paddedPenceNumberString.length - 2) | ||
| .padEnd(2, "0"); | ||
| // At last we get the last two characters as the pence. |
There was a problem hiding this comment.
What else is happening besides getting the last 2 characters?
There was a problem hiding this comment.
In this we stored the last two digits in pence and index 0 character is removed. code is running for getting the last two elements from the currency.
There was a problem hiding this comment.
padEnd() adds characters to the end of string until it reaches a target length. in our code it add 2 character at last.
… values of movieLength.
…ng part of the string as the pound. in 3 to pounds we take out the 2 character and store the remaining part of the string as the pound.
Luro91
left a comment
There was a problem hiding this comment.
Please also take a look at this comment: #1605 (comment)
| console.log(`I was born in ${cityOfBirth}`); | ||
| const cityOfBirth = "Bolton"; | ||
|
|
||
| /*we need to put declare variables(const cityOfBirth = "Bolton";) in first line in second line we use used console.log to print the output*/ No newline at end of file |
There was a problem hiding this comment.
Why does the declaration need to be in the first line?
There was a problem hiding this comment.
The declaration need to be in the first line because without declaration, cityOfBirth does not get any value and show the reference error. So, always variables are declared first.
|
|
||
| // c) Using documentation, explain what the expression movieLength % 60 represents | ||
| // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators | ||
| /*The remainder (%) operator returns the remainder left over when one operand is divided by a second operand. It always takes the sign of the dividend*/ |
| const pence = paddedPenceNumberString | ||
| .substring(paddedPenceNumberString.length - 2) | ||
| .padEnd(2, "0"); | ||
| // At last we get the last two characters as the pence. |
Luro91
left a comment
There was a problem hiding this comment.
@gaireprakash20-ops Thanks for your updates and answering my questions. You can also answer the clarification questions directly in the Github discussions and then do a final commit once we clarified the comment.
In general also try to understand and explain the reason for the code. Not only what does it do from a technical perspective, but what is the reason behind. (e.g Modulo operator give the remainder. It is used to calculate seconds.

Self checklist
Task code
CYF-1039
Changelist
Answer the question and make changes per the question's requirements.