DEV Community

John Roy
John Roy

Posted on • Updated on

Logging Like You're a Lumberjack

I am currently a student at Flatiron School. I am studying Software Engineering. This is my first experience with actual coding aside from some BASIC-language programs in the heady days of Atari 800’s and Commodore 64’s. Coding in JavaScript has been quite the shock to a mind which hasn’t had to think like this in a LOT of years! While it has been very challenging, and quite frustrating at times, there has been one thing that has been to me like a lifesaver thrown to a drowning man - the console.log().

In our prework phase of our bootcamp, console.logging is a part of the curriculum. It’s one of the first things they teach you. They mention that it’s not really part of the actual program, but that it’s more of a programming tool that you’ll use a lot down the road. It really doesn’t seem like that big of a deal. It was not until we started writing functions and manipulating the DOM that I began to appreciate just how much console.logging can do for a programmer. There have been several times when console.logging was the difference between success and failure.

Console.logging is a good way to check your work along the way. Brooke, our primary instructor, harped on us early about console.logging. I didn’t really take it to heart initially. In various one-on-one sessions, instructors would constantly be telling me “Console log it. You just changed something”. If you just picked an HTML element from the DOM, console.log() it and make sure you picked the right one. You just assigned a variable? Console.log() it and make sure that you assigned it correctly. You just did a fetch request? What does the return look like in a console.log()? Knowing that you’ve done things right is really important in every phase of putting together a program.

Console.logging is also great for letting you know what you haven’t done right. No return data from your fetch? Better recheck that resource or check where you actually sent that return. You console.logged in a function and nothing happened? Did you send the right argument? Did you actually invoke the function? And don’t even get me started about console.logging variables. I’ve been coding for real for 3 weeks and I could probably write a book about all the different ways you can jack up assigning or operating with variables!

If it sounds like I love console.log() then I have really understated this post! I try to LIVE it. Every time I write out a bunch of stuff, it inevitably doesn’t work. Then, I have to go back in and try to figure out what’s going on and there’s a LOT to root through. If I had just console.logged as I went, I would at least know what DOES work and if you know that all of your fetch data, DOM elements and variables are right, then you’ve just narrowed things down a lot. Maybe I am a little TOO into console.logging. I console.log() nearly every time I fetch, assign variables, operate on variables, or pick elements from the DOM. It is not the end-all be-all solution, but it certainly has helped me, and made troubleshooting more manageable.

Top comments (0)