Friday ended our first week of Coder Camps. We left with an assignment to whip up a simple quiz app. The requirements were to display 5 questions with 4 answers each, when an answer is selected the user should be informed if the answer is correct, only display one question and answer set at a time, and to keep track of the user's score. The stretch goals were to use CSS transitions and animations, and to display an image for each question. I got it pretty much done by the end of the day Friday and touched it up over the weekend.
You can see it HERE (minus the animations for now)
I went into Week 2 feeling pretty good about myself. Project finish, caught up on sleep. I swear I slept 16 hours Friday going into Saturday with constant vivid dreams. I could practically feel my brains data organization mechanisms firing off. Anyways, come Monday I felt ready to tackle anything. We covered the use of objects and arrays in JavaScript and got an assignment to create a web-form that allows the user to input properties of a "Super Hero" and have those values written to a table on the HTML page. I got through that quickly enough and moved on to the next phase of the project.
We were to create a similar app, but one which utilized an object within the array and had a Delete and Edit button. This Delete button caused me a world of hurt. I figured out the syntax for a function that would delete an object off the array a rewrite the table to display the updated result. I tied the function to a button. When I clicked the button, nothing happened. I relocated the location of the function on the JavaScript page, rewrote the HTML displaying the button, tried alternate functions, combed over every line and character of code I had written. Nothing I did got that button to do anything.
I felt awful going into Tuesday with my assignment incomplete. I had a sinking feeling I would fall behind in the class. But, there was nothing more I could do on my own. I turned the problem over in my mind again and again, approaching from every angle I could consider. I was at the mercy of my instructor and classmates. I both looked forward to and dreaded the moment where my simple oversight was pointed out and my code worked perfectly.
Well, it wasn't as simple as a syntax error or misplaced function call. Turned out I got into trouble because of how I named my function. Apparently, "clear" is a reserve word in HTML. My function was "clear()". A simple renaming to "clear2()" got my function running and those object cleared off of my array. Hours and hours spent trying to fix a problem that was barely there.
There's no way I could have known all the reserved words in any language at this point. It does give give me another perspective to approach debugging now though. I think I see why programmers use exotic, silly names for there variables now. It's too easy to run over a word that has some assigned use in a language already.
No comments:
Post a Comment