X-Press Publishing - step 29: is_currently_employed

I have an issue with what I believe are misleading instructions at step 29. We are being asked to:

[…]check to see if is_currently_employed was set on the request’s artist object. If not, set it to 1 .

Keep in mind that:

  • At no point it has been explained what other values apart from 1 we can expect.
  • Instructions clearly ask to check if the property was set, but they don’t explain what value it returns, if it wasn’t set!

Now, based on all information provided I believe that the correct way of approaching this would be to:

  1. verify whether req.body.artist.hasOwnProperty('isCurrentlyEmployed')
  2. verify whether req.body.artist.isCurrentlyEmployed is defined (!== 'undefined')
  3. based on the outcome of the above steps keep existing value or assign 1

which could look something like this:

let isCurrentlyEmployed;

if(req.body.artist.hasOwnProperty('isCurrentlyEmployed') && req.body.artist.isCurrentlyEmployed !== 'undefined' ) {
    isCurrentlyEmployed = req.body.artist.isCurrentlyEmployed;
} else {
   isCurrentlyEmployed = 1;
}

Right?..

Wrong.

As it turns out the expected solution passing the test is:

const isCurrentlyEmployed = req.body.artist.isCurrentlyEmployed === 0 ? 0 : 1;

which loosely translates to “Check if property value is set to 0. If it is, keep it - otherwise make it 1.”
To me this is something completely different than what we read in the instructions.

Also, what’s the point of making ‘is_currently_employed’ DEFAULT to 1 in our schema, if we are assigning and passing value to it anyway?..

So, am I missing something or are these instructions simply wrong?

Hi there, Michael. Can you attach the URL to this project so we can take a look at the instructions? Thank you :slight_smile:

Hi, lilybird

Thank you for checking. Sure, it’s one of the Persistent API Cumulative Projects, step 29:

https://www.codecademy.com/paths/web-development/tracks/building-a-persistent-api/modules/persistent-api-cumulative-projects/projects/x-press-publishing

However, if you look through the forum posts relating to this and the following project (Expresso), you will find that there are a lot of issues regarding both projects. The biggest issue seems to be that both projects use old and depreciated dependancies causing issues i.e. sqlite crashes when you strat your server. Forum users come up with elaborate workarounds which work for some and not for others.

Given that updating/fixing dependancies is something that developers must do frequently, perhaps it would be a good idea to provide a lesson or a couple of articles explaining how to deal with these sort of issues.

In my comment above I was referring to step 29 in particular, because personally I think the instructions are simply misleading. But in truth, I believe the entire SQL lesson pack suffers from often unclear instructions or useless hints. For instance here:

https://www.codecademy.com/paths/web-development/tracks/building-a-persistent-api/modules/learn-node-sqlite-module/lessons/learn-node-sqlite/exercises/serial-queries

In step 4 instructions tell us to write a bit of code that

After all your rows have been inserted with the averageTemperatureByYear.forEach() loop inside db.each() , create a new db.all() query to SELECT all rows from the Average table and printQueryResults() with the transformed data!

Again, if you check the forum posts for this exercise you will see that there are different ways this could be interpreted as to where exactly you should insert the db.all() query. Should it be nested inside the ```db.each()’’’ statement or perhaps it should be used with db.serialize() statement.
After reading these instructions I wasn’t sure myself, so I clicked on the hint to find this…

Use db.all() to select many rows.

Useful, right?
:rofl:

Anyway, thank you for chasing this up. It’s always reassuring to see the Codecademy team is looking into these issues.