FAQ: Code Challenges - Code Challenge 7

This community-built FAQ covers the “Code Challenge 7” exercise from the lesson “Code Challenges”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Web Development

Learn Node-SQLite

FAQs on the exercise Code Challenge 7

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

What is the difference between ‘console.log()’ and ‘printQueryResults()’?
Doesn’t ‘printQueryResults()’ print the results also?

If, how do they differ?

Yes, from what I tested, both provide the same result.

I do believe the main difference is that we can’t use printQueryResults() calls outside of Node-SQLite queries, while we can use console.log() everywhere using JavaScript.

I might be wrong though, so if anyone knows better, please let us know.

Because only the quantity column has been selected, why do I need to print row.quantity? Wouldn’t just row suffice?

db.get("SELECT quantity FROM SpiceRack WHERE name='paprika'", (err, row) => {
  console.log(row);
})
db.get("SELECT quantity FROM SpiceRack WHERE name='paprika'", (err, row) => {
  console.log(row.quantity);
});
1 Like

I am confused about this too.
Looking at courses/learn-node-sqlite/lessons/learn-node-sqlite/exercises/retrieving-a-single-row
using console.log(row) outputs an object(?): { temp_avg: 19.650000000000002 }
using console.log(row.temp_avg) outputs an intger: 19.650000000000002

(correct me if I’m wrong.)