26-itp-1 | Benjamin Vanderzeypen | Sprint-1#56
26-itp-1 | Benjamin Vanderzeypen | Sprint-1#56nuttyproducer wants to merge 9 commits intoHackYourFutureBelgium:mainfrom
Conversation
d5ed316 to
a80cb78
Compare
Add totalDays to our logic.
Also added some extra features that i'm learning on the side. I want to see Dashes between the every 4 numbers.
robertopaixao
left a comment
There was a problem hiding this comment.
You exercice looks great, just some tips and few comments for check.
| let count = 0; | ||
|
|
||
| count = count + 1; | ||
| count = count + 1; // = assigns a new number to count = 0 -> 1 |
There was a problem hiding this comment.
Looks good, and as a tip, if you want to increment an existing variable, you can also rely on the ++ operator.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Increment
| const remainingHours = totalHours % 24; // leftover hours after counting full days | ||
| const totalDays = (totalHours - remainingHours) / 24; // total full days | ||
|
|
||
| if (totalHours >= 24) { |
There was a problem hiding this comment.
Your condition is showing the days when there are no days and not showing when it should show.
So, there is an error here in the structure.
There was a problem hiding this comment.
I have changed the condition to if (totalHours < 24). This will switch both our console.logs.
| @@ -1,25 +1,41 @@ | |||
| const movieLength = 8784; // length of movie in seconds | |||
| const movieLength = 2603; // length of movie in seconds | |||
There was a problem hiding this comment.
Try to use a movie length of 3661, and you will see something not fully correct in the output of your program.
Let me know if you cannot identify it
There was a problem hiding this comment.
Ohhh I see @robertopaixao It will give you an output of 1:1:1.
So what we need to do is again call method .toString() + .padStart(2, "0")
| maskedWithDashes += masked.slice(i, i + 4); // Add the next group of 4 characters | ||
| } | ||
|
|
||
| console.log(maskedWithDashes); // Output: ****-****-****-4213 |
There was a problem hiding this comment.
Nice that you use the pad here. You are assimilating things fast.
Also totalhours should be remaining hours in console.log of else
Learners, PR Template
Self checklist
Changelist
I've updated all the exercises in Sprint-1 on the branch /coursework/sprint-1
Questions
I have created a bunch of other exercises in the prep folder. Is anyone interested in seeing them?
I create a second PR with only the extra prep material.