Console.log()

Amelia Haba
2 min readJun 20, 2021

Switching from writing Ruby on Rails to JavaScript has been extremely challenging. Though many of the concepts are similar, the syntax is very different. Connecting the front-end of the application and the back-end of the application really tests your knowledge and understanding of both languages.

I definitely struggled (still am!) and I relied heavily on a function in JavaScript called Console.log() to help me debug and better understand what information I was getting back.

Console.log() is a function that is used to print variables, check your variables, and print messages that need to be displayed to the user.

I used console.log() many times to just double check that the variable I was getting returned was what I expected. This was one of those “sanity checks” to make sure I was on the right track with my code. This is useful to do every-so-often to make sure you don’t run into bigger issues later on.

If I did happen to run into an error, console.log() definitely helped me solve my problem! While I was creating my app, I would refresh the page and would see a red error message. Many times the error would indicate that something was null, didn’t exist, or was undefined. I would go back into my VS code and type out console.log() and pass in what I was needing to check. I would then open up the console and see what the variable was. Understanding that my variable was null or undefined would help me solve the issue by checking other parts of my code and making sure the correct information was being passed through.

Console.log() takes less than 30 seconds to code out and check. Using this function is a very easy and helpful way to make sure your app is running properly.

Example of console.log()

--

--