0

I'm recording this time and date for posterity - January 18, 2015 at 5:03 p.m. (Pacific Time). What is the significance of this moment in history? It's the exact time and date that I finally solved what was probably the most plaguing problem I've ever encountered in any subject I've ever studied. Some of you might be thinking to yourselves, "javascript... really?" Well, keep in mind that I'm still fairly new to programming. Also, maybe the reason I had so much difficulty with a javascript problem is because I'm not the super genius that many of us wish we were. Wouldn't life be so much easier as a super genius? Well, maybe not, but that's a discussion for another time.

I had been trying to solve the same problem for the past five weeks. I tried everything I could think of, watched video tutorial after video tutorial, constantly hit the text tutorials at w3shcools.com; youtube was no help, w3schools only echoed what I had already learned, my patience had expired weeks earlier, I cursed javascript for being a worthless language that didn't do what I wanted it to do, and I was on the verge of ripping my hair out. I even questioned my intellectual capacity for learning how to code. The only thing I had left was my perseverance; my unwavering desire to learn how to code no matter how many months or years it would take me and regardless of how vexing the potential obstacles might be. And without that perseverance I wouldn't be writing these words that will hopefully offer at least some level of inspiration to others who, like myself, have experienced what it's like to be halted by seemingly insurmountable adversity - not just in the field of programming, but with any worthwhile endeavor.

Oh, and you might be wondering about the problem that was so vexing and so difficult that it took me five weeks to figure out. Well, I was trying to make a circular teal div move 800 pixels to the right, then move back to the left again. No matter what I tried, it would always stop at 800 pixels and refuse to move its lazy round block-level behind another inch. Just when I was about to seek help from Daniweb, which I only recently started using, I decided to try one final alteration to my code - I changed the order that my clearTimeout() appeared in my conditional statement. I moved the clearTimeout() four lines down to the bottom of the conditional statement. That was it. That was all I had to do to make my code work. And it did. This experience reminded me of a quote from Winston Churchill in which he said that "Americans will always do the right thing, but only after every other possibility has been exhausted." Oh, well. Live and learn.

Now I can gather up all of my luggage that's filled with knowledge and experience, and get back on the progress train. My head is held high, I'm standing tall, and I'm imbued with new confidence that I can achieve my goal of being a self-taught programmer. And that's the importance of perseverance.

Edited by pritaeas: Moved to Geek's Lounge

4
Contributors
4
Replies
63
Views
3 Years
Discussion Span
Last Post by DaniUserJS
0

And I say kudos to your achievement. Persistence is the key indeed.
But, and I don't mean to belittle what you've done, true knowledge comes when you know WHY moving that line of code made the difference.
Have you solved that particular question?

0

I agree with Hericles that this is an impressive but incomplete achievement. Once you know why moving that line made the difference, a very important step is to find the tools, which necessarily exist, which would have turned these five weeks of nightmare into a few hours, or a few seconds.

These tools show you in a visible way what is going on in your code when something goes wrong. The quest for these tools may save you years of bug finding.

0

Also not to belittle your achievement, but there are specific frameworks for javascript animation, which looks like what you're doing. Use them and abuse them. That's what they're there for. Pure js sucks ass, that's my personal biased opinion.

0

Yes, iamthwee, you're not the only one who thinks pure JS is a bad way to go. I've heard comments from other programmers who share your opinion. That's okay, because I have to learn to crawl before I can walk. I'm not running off to learn Angular and Ajax just yet. I'm aware of the requestAnimationFrame() function and I've recently watched a Youtube animation tutorial in which it was suggested that something other than style.left and style.top should be used. I'll get to these things in time, just as I'll eventually find out what a "framework" is. At the moment, however, I'm just trying to master vanilla javascript.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.