DEV Community

Cover image for Starting JavaScript Today – My First Attempt.
Yasmin
Yasmin

Posted on

Starting JavaScript Today – My First Attempt.

1 / 30
Hi y'all!
Today I tried learning JavaScript for the first time. I wanted to start earlier, but college exams… and, well, laziness 😅 delayed me. But I finally started!

I studied a little today and went through the basics .. functions, variables, return, objects, arrays, loops. Honestly, even just covering this felt good and gave me a bit of energy and motivation.

The tricky part for me was the fill() method for arrays. At first, it seemed simple, but I just don’t fully understand how it works, especially the end part. I’ve tried reading about it and looking at examples, but it’s still confusing.

console.log([1, 2, 3].fill(4, 1, 2)); // [1, 4, 3]
Enter fullscreen mode Exit fullscreen mode

..For example, if the array is [1, 2, 3] and arr.fill(4, 1, 2), the result is [1, 4, 3].
Wait… How? ..The rule says the first number in fill is the value (4), the second is the start index (1), and the third is the end index (2).

Step by step.. the value is 4, okay, so all positions should get 4. The start index is 1, okay.. we start at position 1. The end index is 2, so… why does position 2 STAY 3 ??! How does that happen?

I also started feeling a bit frustrated with programming in general. Sometimes it feels like I’m not making progress, and it’s hard to stay motivated. I even start thinking maybe I’ll never find a job… very pessimistic, I know. 😅

Anyway, I’ll post again tomorrow about what I study next, And these are some other examples I didn’t fully understand either. If anyone understands fill(), especially how the end parameter works, I’d really appreciate some help before my brain explodes.

Top comments (0)