So I’ve currently seen every lesson and coded along/trying to take notes up to and including ‘control flow’ in Ultimate JavaScript Part 1: Fundamentals . Exercises 1 to 5 I could do on my own, but from there not a single exercise I could finish without watching Mosh explaining the entire exercise…
I feel like I can think up how I want to solve an exercise, but cannot put it into code myself. What am I doing wrong? Is it normal that I’m feeling this way?
With the HTML/CSS course I could basically get to the solution most of the times, if only helped a little bit at the end. Even then Mosh adressed it as “if you could not do it, don’t worry”, but now with JS, I feel like I should be able to do every single exercise but can’t even get started on one…
Let me know if this is regular and if not, how to fix this…
Programming is a little different than HTML and CSS, but it doesn’t have to be harder. The way I was taught, and the way I still sometimes do is by writing what I would be doing in the code, but not exactly something a computer would understand. We call it a “pseudo code”.
I think Mosh has talked about it in some course as well. For instance, if I am writing a code that returns the largest number in an array, I’d write this pseudo code:
let largest = first element
let index = 1
If "largest" is less than the current, largest = current
Index = index + 1
If reach end of array, print "largest"
Now I will start replacing each line with the actual code, sometimes I’d need to Google the syntax and sometimes I’d even need to see how to “iterate an array in JavaScript”.
You can even start with something like this, which is how you’ll be thinking:
Read each element one by one.
If current element is larger than the largest value encountered, remember it as largest.
If all elements are read, print the element known as largest.
In this pseudo code, I just stated how I will find the largest number in an array myself, which is key. If you can write steps that you can follow to do a certain task, you can also tell your friend (a computer) how you do it as well. You’d need to translate it to their language, however.
The idea is to take things step-by-step. I often see people jumping to code straightaway, and it just makes things very hard. Just take things step-by-step and gradually you’d be as quick as Mosh.
Hi.
That’s what we call learning.
I’m rather on the stuborn side so I try quite hard to finish on my own but sometimes you may simply need to go for the answer. Try and then accept you’ll see the answer if you just can’t get there.
Pro Tips: Have your own project and apply what you’ve learned (if it makes sense).