Journey is not always more important than the destination.

(Spoiler alert! – This is a newbies’ take on writing first blog post about coding – all part of @Scrimba #JavaScritpmas Advent calendar )

It has been said many times in books, movies, and Facebook posts that journey is more important than the destination. I have also experienced this feeling time and time again, especially traveling abroad or going on a hike, and always thought it to be true. However, during last ~6 months, which I have spent trying to learn how to code, I am starting to wonder if this statement might have some loopholes.

As many fellow beginner trying-to-be-self-taught programmers, I have spent crazy loads of time following online tutorials, courses, listening to podcasts and solving beginner level challenges . Feeling of despair and “What am I doing here?” has been ever so present many times. On the other hand, I have also had many moments, when I get adrenaline rush and want to do a little dance of joy around my room, because I see my program doing what I imagined it would do! And with little reflection it is not hard to notice, that those moments of joy come after I’ve been pursuing a certain goal – creating my first website with HTML&CSS, creating a word guessing game from scratch with JavaScript or preparing myself for a test to enter a Java bootcamp.

It is true that on the journey of reaching my goals I have discovered unexpected bits and pieces of knowledge, which I did not think (or even know) I will need in the first place. However, just “being on the road” (e.g. following a tutorial with a vague aim “want to learn to code”) has brought more sense of being lost than joy of learning and discovery. After all, you can only split an imaginary string so many times! I have realized that it is important to have an end-point, a tangible result in sight - or at least somewhere in the mist further along the road - in order for me to be able to evaluate and describe the progress I have made. And I think it is important to be able to put my learnings in words.

But goals do not need to be huge all the time. Even solving a small challenge found online can be a motivation for the day to keep learning. So, when, by accident, I saw #Javascriptmas Advent calendar, I did not think twice if I should join it or not. Even though, it was already day 5 when I discovered it, I quickly caught up and since then have been waiting for the daily challenges to solve. Bellow there is a list of all of them with some comments about the solution, or the things I learned by solving them. Hope you will enjoy and any feedback about my solutions is welcomed!

Day 1:

Candies - an easy one to start with. It has been a surprise to me time and time again, how handy a modulus operator (%) can be.

Day 2:

Deposit profit - keeping it simple - a while loop and basic math skills.

Day 3:

Chunky Monkey - I don’t know where the Monkey comes in play, but did some slicing and tests ran green. Maybe I did it in more lines of code than needed, but I kind of still need this step-by-step approach to functionality of my code.

Day 4:

Century from number here I was just excited to use a ternary operator.

Day 5:

Reverse a string - split... reverse… join… repeat… I’ve heard about reversing a string as a tough question in coding interviews, however, after encountering it several times, I am not afraid of it anymore. Especially in JavaScript!

Day 6:

Sort strings by length - sorting now also seems quite an easy task. I do not fully understand all the return a-b under the hood operation, but hey – it does it’s job and I get my tests green.

Day 7:

Vowels and consonants - this was a nice challenge to practice JavaScript array functions. Easy sailing so far!

Day 8:

Rolling dice - “Wow, wow, wow – what is going on here?! Out of the blue such a challenge! I am no so familiar with using JavaScript in DOM manipulation yet!? Isn’t this quite a leap from the level of previous challenges?” – was thinking I, when opened this task. I did begin to create more dots for the dice, but failed miserably in positioning them correctly. After half an hour of torturing myself and the pour dice with endless pixels of margins, I… gave up… Who cares…? It’s just a random challenge…

Day 9:

Sum odd Fibonacci numbers - ok, we’re back to business! This is something I have seen before and probably will do in no time! Yep, used recursion, did it in 10-or-so minutes, posted online and went on to see how others solved it. And such was my surprise when I saw the tweet of @nykicodes which said

and then somebody continued

Wait, whaaat? From what I have heard so far, I had an impression that recursion must be like “the best thing ever”, when solving repetitive tasks?! But ok – after some time spent googling “Why recursion is bad for Fibonacci?” I kind of got the idea. Went back to modify my solution and noted to myself: "Browse before recurse!”

Day 10:

Adjacent element product - this one also seemed quite simple. I have seen before how to find the biggest value in an array using for loop, so was not too startled.

Day 11:

Avoid obstacles - I felt like I traversed this obstacle course in big, clumsy rubber boots, but got on the other side in the end, so – happy days!

Day 12:

Validate time - I have no idea if this is how time entries are validated in real life (probably there is some in-built JavaScript functionality which deals with dates and times), but other than that the task felt pretty easy. BTW – this was by far my favorite challenge, because I finally, for the first time in my life won anything on any kind of internet lottery – I got a one year subscription for Scrimba courses! I was even more excited to see, that one of the course teachers is Kewin Powell , whose CSS tutorials I’ve been enjoying watching on Youtube, so I guess the courses are the real-deal! Looking forward to start year 2021 with discovering more about web development!

Day13:

Extract K-th - even though it sounds like a task to split up Rolling Stones, actually it is much easier. Modulus operator (%) strikes and saves the day again!

Day 14:

Maximum adjacent difference - here I felt like solving the task by just using brute force. Nothing elegant, but it works.

Day 15:

Carousel - Oh, wow! Another complex task! But somehow this time I felt that I can do it! (Actually, I was just happy that the the difficulty stayed on the level of my comprehension and we were not challenged with React or something along the lines). Either the presentation of challenge was quite clear or I was just having a good day - I did finish the task in 20 minutes and 17 lines of JavaScript! Event though few months ago I would have had a faintest clue about what to do here. Good job, me! (Maybe I should look one more time at that Rolling dice challenge?) PS. Saw somebody copying my solution for this challenge. Will take that as a compliment!:)

Day 16:

Insert dashes - split... split… join… repeat.

Day 17:

Count different symbols - I enjoyed this challenge, because it made me look up and learn something new – what is a Set() in JavaScript. I know, that I didn’t use it’s full potential here, but I was just happy, that I managed to make my code work with something I had just learned 5 minutes ago. And it was fun also to come up with different test scenarios.

Day 18:

Smallest closest - this task caused some discussions on Scrimba's Discord channel , since it could be interpreted in more than one way. I did it how I thought it should work, the code looks quite ugly – a lot of pushing going on there – please, don’t judge too hard!

Day 19:

Alphabet sequence - I find it quite peculiar how it is possible to use comparison operators on letters.

Day 20:

Domain type - I am doubtful if my solution would work in real life situation, but, here I was just glad to see a practical use of switch instead of “if.. elses”.

Day 21:

Sum of two - I did see people playing “coding golf” (trying to code in as little characters as possible), but I am quite happy with my solution. Golf doesn’t attract me much as sport:) Also – was curious to see how can I use the hint hasOwnProperty() in the solution, but ended up using includes() instead of it. Still don’t know, how the hint could have helped me.

Back to the future - Day 8:

Rolling dice - finally I worked up the courage to do also this one! I was glad that finally all the time I had spent watching CSS Grid videos by Jen Simmons paid off! It turned out, that positioning dots was not such a pain in the butt after all. Of course, maybe there is more elegant solution to changing dot count on dice roll, but I will take my solution every time of the day.

Day 22:

Column from Matrix - this task sounds scarier than it is. I had a feeling, that I should use map() here, but I had a brain freeze moment and used different array functions.

Day 23:

Tweet component - All right, back to HTML, CSS and JS all together! I am not afraid to admit, that I spent 3 hours solving this task. Most of the time I spent figuring out if I should listen to keydown or keyup event, but since keydown makes the counter run in case when a key is pressed and not released, I opted for this one. Had to spend some time to figure out how to handle “Backspace” being pressed. No clever or short code here, but it works and I’m glad I did not give up

Day 24:

Spinning wheel - the journey has come to an end! First, I created a solution with "for..." loop, but then went back to it and re-did using "do... while" loop, since I thought that it might suit better for this task. Anyway - feeling lucky? Try the game!

In conclusion - this was definitely a fun way to fill long and dark December days! Big shout-out to nice people at Scrimba - keep up the good work!