FAQ: Code Challenges - Code Challenge 5

This community-built FAQ covers the “Code Challenge 5” 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 5

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!

In the directions for this exercise, it says

Each row’s price property is already a number, so you do not need to use Number() to convert it.

But in the solution:

 totalPrice += Number(row.price);

is this a mistake?

1 Like

Hum, that’s odd.
My code below passed:

const db = require('./db');

let totalPrice = 0;
db.each(
  "SELECT price FROM Clothing WHERE item = 'shirt'",
  (err, row) => {
    totalPrice += row.price; 
  },
  (err, numRows) =>{
    console.log(totalPrice);
  }
);

So I assume the solution is just another way to do it, although the Number() call here is totally optional (and even discouraged, as you mentioned straight from the instructions). :man_shrugging: