# Help please, just started learning javascript

**URL:** <https://forum.codewithmosh.com/t/help-please-just-started-learning-javascript/12732>\
**Category:** JavaScript\
**Created:** [May 30, 2022, 10:23am UTC](https://forum.codewithmosh.com/t/help-please-just-started-learning-javascript/12732 "2022-05-30T10:23:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![MattJr](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/mattjr/32/3843_2.png) [@MattJr](https://forum.codewithmosh.com/u/MattJr)\
**Post date:** [May 30, 2022, 10:23am UTC](https://forum.codewithmosh.com/t/help-please-just-started-learning-javascript/12732/1 "2022-05-30T10:23:57Z")

</div>

Hey guys, i could really use some help here. I’ve tried countless times to understand what Mosh did here, but i haven’t been able to. I’d really appreciate any help.

 ![Screenshot 2022-05-30 at 11.56.52](https://us1.discourse-cdn.com/flex020/uploads/codewithmosh/original/2X/a/a9eb389e12ad0e299baeae8b9df3c7b64e80f3af.png)

---

<div class="post-metadata">

**Author:** ![UniqueNospaceShort](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/uniquenospaceshort/32/1814_2.png) [@UniqueNospaceShort](https://forum.codewithmosh.com/u/UniqueNospaceShort)\
**Post date:** [May 30, 2022, 11:26am UTC](https://forum.codewithmosh.com/t/help-please-just-started-learning-javascript/12732/2 "2022-05-30T11:26:52Z")

</div>

Hi,  
I don’t take his JS course so I don’t know the full code but it seems it is computing a number of points you remove from a driving license.

So if your speed is under the speed limit you just display OK.  
Else you may have several scenarios.

The first step is common to each and it computes the number of points to remove.

I believe the `kmPerpoint` (kpp) identifier is a constant for which you remove 1 pt on the license.  
So say the speed limit is 50 Km/h and the `kpp` is 2.  
You drive at 52 Km/h you are removed 1 point. 60Km/h you are removed 5 points.

The formula is flooring the delta between speed and the limit divided by `kpp`.

Should you need to understand `Math.floor` see the doc [@MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/floor). For short it rounds to the closest integer bellow the value.

Here are samples.

| S | SL | ΔSSL | R1 | RTotal | Effect |
| --- | --- | --- | --- | --- | --- |
| 0 | 50 | -50 | -25 | -25 | OK |
| 50 | 50 | 0 | 0 | 0 | OK |
| 100 | 50 | 50 | 25 | 25 | L.S. |
| 60 | 50 | 10 | 5 | 5 | -5 Pts |
| 35 | 50 | -15 | -7.5 | -8 | OK |
| 65 | 50 | 15 | 7.5 | 7 | -7 Pts |
| 73 | 50 | 23 | 11.5 | 11 | -11 Pts |

Columns:

- S: Current Speed
- SL: Speed Limit
- ΔSSL: Difference between current speed and limit
- R1: Result of ΔSSL divided by `kpp`
- RTotal: Final result

`kpp` has the value of 2.

Effects:

- OK: You can go ahead without any consequence
- L.S. : License Suspended
- -X Pts: Number of points removed where X is that number of points.

So:

- Over 12 points included your license is removed.
- Under 12 points you remove the computed amount of points.

I hope this helped you understand.

Good luck with your course.

---

<div class="post-metadata">

**Author:** ![MattJr](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/mattjr/32/3843_2.png) [@MattJr](https://forum.codewithmosh.com/u/MattJr)\
**Post date:** [May 30, 2022, 1:18pm UTC](https://forum.codewithmosh.com/t/help-please-just-started-learning-javascript/12732/3 "2022-05-30T13:18:18Z")

</div>

Please elaborate  
I took a better screenshot, so you’ll be able to see the code fully

---

<div class="post-metadata">

**Author:** ![UniqueNospaceShort](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/uniquenospaceshort/32/1814_2.png) [@UniqueNospaceShort](https://forum.codewithmosh.com/u/UniqueNospaceShort)\
**Post date:** [May 30, 2022, 2:00pm UTC](https://forum.codewithmosh.com/t/help-please-just-started-learning-javascript/12732/4 "2022-05-30T14:00:45Z")

</div>

Well thanks for the updated screenshot. It confirms my thoughts.  
Better than screenshot copy paste your code should you ask new questions in the future. This would make anyone’s life trying to help easier.

You can use [markdown](https://www.markdownguide.org/cheat-sheet/) to surround your code. This is simple to learn and useful when you write documentations.

Now I don’t see how I could elaborate anymore. Please read my answer carefully.
