Stock Price Checker requirements are confusing me

Hello,

I’m currently working on the stock price checker but these two conditions below are confusing me. Can anyone please make it clearer for me. Thank you.

  1. I can also pass along the field like as true (boolean) to have my like added to the stock(s). Only 1 like per IP should be accepted.
  2. If I pass along 2 stocks, the return object will be an array with information about both stocks. Instead of likes , it will display rel_likes (the difference between the likes) on both.

https://www.freecodecamp.org/learn/information-security-and-quality-assurance/information-security-and-quality-assurance-projects/stock-price-checker

1 Like

Hi @stel, I confess I was bit confused in the beginning with the requirements too. But now I get it and this is how I’ve interpreted them:

  • the first requirement basically tells you to save likes exclusively based on the IP address that did the request. Something like this:
db.collection('stock').updateOne( 
   { stockTicker: element.stockTicker },
   { $addToSet: { "like": { ipAddr: ip } }}).then(function(result) {}

That’s the part of my code where I save a new ip address to an existing stock ticker object only if the ip address isn’t already there.

I guess for the second requirement we just need to show the total likes each stock ticker have received, but I haven’t finished that yet. I’m really stuck with MongoDB find() and findOne() methods.

1 Like