London | 26-ITP-JAN | Shuheda Begum | Sprint 1 | Structuring and Testing Data#937
London | 26-ITP-JAN | Shuheda Begum | Sprint 1 | Structuring and Testing Data#937codebyshay wants to merge 19 commits intoCodeYourFuture:mainfrom
Conversation
Initials fixed
const dir and const ext
What does num represent with explanation
Adding // to make a comment or add instructions for human consumption.
let allows variable age, const does not.
Swapped the position of const from under the console to on top of the console to allow javascript to read it in order.
Add String to the cardNumber so javascript recognises it as a string and not just numbers, making it possible to slice.
SyntaxError fixed..twelve instead of 12 and twentyFour instead of 24
Answered all questions and added , to the function.
Answered questions
Explain each step one by one.
Answered questions and tried alert and prompt on chrome dev tool.
Completed dev tool exercise on chrome.
Sprint-1/2-mandatory-errors/1.js
Outdated
|
|
||
| // The code above will output 34, because we are reassigning the value of age to be the current value of age plus 1. So, 33 + 1 = 34. | ||
|
|
There was a problem hiding this comment.
Do you think the explanation provided here hit the major reason why the error was occurring even if you did the right thing in your code?
There was a problem hiding this comment.
No. I have now included this . Thank you.
Sprint-1/2-mandatory-errors/3.js
Outdated
| @@ -1,9 +1,12 @@ | |||
| const cardNumber = 4533787178994213; | |||
| const last4Digits = cardNumber.slice(-4); | |||
| const last4Digits = String(cardNumber).slice(-4); | |||
There was a problem hiding this comment.
Now, you did the right thing by explaining your reasoning to debug the error. I would suggest applying a much cleaner way to convert the variable into a string without redeclaring it. You can look into that method using MDN docs.
|
|
||
| // f) Try experimenting with different values of movieLength. Will this code work for all values of movieLength? Explain your answer | ||
|
|
||
| // This code will work for all positive integer values of movieLength. It will correctly calculate the hours, minutes and seconds for any length of movie. However, if movieLength is negative or not an integer, the code may not work as intended. For example, if movieLength is -100, the calculations will not make sense in the context of a movie length. If movieLength is a decimal, it may also cause issues with the calculations. No newline at end of file |
There was a problem hiding this comment.
Have you considered if there could be some time formatting issues with smaller integer numbers?
There was a problem hiding this comment.
I didn't think of that. I will have a look at this now.
Theoreoluwa
left a comment
There was a problem hiding this comment.
Great job so far; kindly look into the comments to make it better. Well done.
Code amended to allow shorter times.
|
Thank you. I've looked though the comments and have amended as necessary. |
|
|
||
| const movieLength = 65; | ||
|
|
||
| const remainingSeconds = movieLength % 60; | ||
| const totalMinutes = (movieLength - remainingSeconds) / 60; | ||
|
|
||
| const remainingMinutes = totalMinutes % 60; | ||
| const totalHours = (totalMinutes - remainingMinutes) / 60; | ||
|
|
||
| const formattedHours = String(totalHours).padStart(2, "0"); | ||
| const formattedMinutes = String(remainingMinutes).padStart(2, "0"); | ||
| const formattedSeconds = String(remainingSeconds).padStart(2, "0"); | ||
|
|
||
| const movieDurationString = `${formattedHours}:${formattedMinutes}:${formattedSeconds}`; | ||
|
|
||
| console.log(movieDurationString); // 00:01:05 |
There was a problem hiding this comment.
While I understand you might have misinterpreted my comment, the point I made was not for an explicit change of the code to work with a certain range of numbers. The rationale, as seen in the task, is to explain your rationale for your answer as to how various values will work when passed into the movieLength variable.
Theoreoluwa
left a comment
There was a problem hiding this comment.
Well done. Great job. I will mark the task as complete, but I would encourage you to check through my comment and ensure you understand the task requirements properly. Keep going!
|
Thank you! |
Learners, PR Template
Self checklist
Changelist
Did exercise 1.
Questions
N/A