DEV Community

CodeCara
CodeCara

Posted on

Shhhhh....the Library Project

(Should have been posted yesterday)

I will keep this post shorter than usual this week for two reasons:

  1. I had much less time than usual to work on the project and found myself doing maybe an hour at a time, which I found unproductive as I had to try to pick up from where I left off each time and go over what I had done before each time.

  2. My record-keeping was a bit lax this week due to my lack of time.

Things I've worked on/completed since my last post...

The Library project.

Things that went well...

I found the basics/previously-covered material coming to me much faster:

  • Creating elements on the DOM
  • Adding event listeners
  • Using the constructor function

Things that didn't go quite so well...

I ran into some scoping problems when I tried to implement a function within a function which could not be solved by using a global variable, but I solved this by referring to the array item rather than the variable

Though this was not a huge problem, when I tried to implement the preventDefault() method to stop the data in the form from being submitted when clicked, I was unable to get it working and I noticed that in my code, ‘event’ appeared to be deprecated . It turned out I had omitted event as a parameter. I should probably look further into what was going on there to make sure I understand it better.

A bigger problem was in the loop I had to create the required new elements on the DOM. The loop itself was fine, but in order to avoid duplication, the nodes needed to be deleted and recreated on subsequent clicks.

I wanted to delete those nodes outside of the for loop I had, but of course this didn’t work as there were undefined upon first button click as they had not been created yet.

With the help of a fellow Odinite, I figured out that I could clear those newly-created elements by setting the innerHTML to an empty string, which circumvented the problem I was having. Although the solution was not complicated, it was new to me and so I am not sure I would have ever figured it out(!). In any case, it will hopefully stick in my brain, should I encounter the same problem again.

Things I've learnt/need to improve on...

One thing that really affected my progress in a negative way was working for periods of time which were too short as I found it very distracting, although it was only done due to unavoidable time constraints I had this week. I’ve learnt that I would probably have been a lot more productive to work for three hours straight, rather than four sessions of 45 minutes. This may be different for other people, but I think I am better suited to longer sessions where I can concentrate for longer periods of time.

Plan for the forthcoming week...

I will finish the library project this week.

Did I say this last week? If I did, then I really will finish it this week.

Top comments (0)