Hello Chandler1,
I feel your frustration. It’s all of those maths examples that confuse me.
First of all, ‘teaching yourself’ is somewhat mythological because you use a source to learn from, in your case Treehouse, Colt Steele and Jon Duckett; they are your teachers.
JavaScript can be challenging.
You have done some projects; code alongs? Try code alones. What I mean is, after doing a code along, try making a similar app on your own. That way you can practise what you learnt in the order you learnt it.
Another thing to do is try to get out of the tutorial environment and think of your own project. I haven’t done a tic-tac-toe game, calculator or drum kit. I was thinking of making an electronic keyboard because my wife won’t let me have a keyboard.
To think like a developer, develop your own things. It will force you to think of all aspects of the program. For example, I did something over the last few days that really got me thinking about what I wanted a program to do, and it stretched my coding ability. I thought it would be fairly simple, but the more I went into it, the more things I discovered needed fixing. My project was to develop an ACT essay writing practice program to help my ACT students practice essay writing under timed conditions. Here’s what I thought about and the process I went through:
- The program should allow students to write essays.
- A timer should disable the page when time is up.
- The program display the number of characters remaining (down from 10,000).
- The essay is stored in local storage as it is typed.
- The program makes a file from the essay (pass local storage variable to php from a form).
- The program e-mails the essay file to the student and tutor.
Once I knew what I needed to do, I started making each part at a time.
I originally had a setInterval
timer, but found out that they are inaccurate. I found a great tutorial on Wes Bos’ Javascript 30 course to deal with that. So, I got the timer working and all of the disabling and enabling of different elements.
I got the essay into local storage, but I was flummoxed at trying to get it into php. Stack Overflow to the rescue. Hmm, it was a simple case of passing the essay string via a hidden form input to the php script.
Next was how to actually send an attachment. phpMail makes it hard work. So I Qwant searched and found a script called phpMailer, which seemed to be extremely popular. I got that running after a few snags.
Everything worked well, or so I thought. There were issues with the character count and every key down counting the counter down. I did more Qwanting and discovered event.key
. I coded a regex for the characters that I wanted to count down the counter as an initial condition for an if
block, I then had to exclude the event.key
s that a user presses but should not have a value (Shift, Tab, arrow keys…) so they did not count the counter down. The thing then was that deleting needed to increase the counter.
Anyway, I won’t go on any longer. I learnt a lot by completing my own project. You should see that creating your own wok and getting stuck is an opportunity to learn how to do something and get into the habit of searching for solutions. My code may be messy and inefficient, but as I improve, I should be able to refactor it.