-1

What I am trying to implement is that after some interval of time, it checks the MarketWatch site to see if there's a new link in the news finder section of the latest news page (using the scrapeArticle function) and if there is a new link (article) it will send it into the discord chat.

From lines 16-38 was my attempt at doing the above. Although a sloppy method, I could not think of any better way of implementing that, that isn't error prone. The current problem (logic error) is that it repeats the last article after posting in chat the new one. Here is what that error looks like: Error Image

Here's the entirety of my code:Part1 Part2 Part3

I am a beginner programmer and new to using Stack Overflow as well. I hope my comments and screenshots help. If you have any questions regarding the question, please ask. Any and all help would be appreciated.

  • Hey, welcome to stack overflow. Please read [this quick explanation](https://idownvotedbecau.se/imageofcode) of why you should never provide images of code or errors. – Lioness100 Nov 21 '20 at 12:54

1 Answers1

0

Remove the delete oldLink line, there's no need for that. As an aside, you should use === for equality comparison

holtc
  • 1,780
  • 3
  • 16
  • 35
  • Forgive the ignorance, but for clarification, I should delete it because the variable will be assigned a new value regardless? Also why would it be preferable to use '===' as opposed to '=='. (I have made the changes and will monitor and watch for new articles to be posted on the site in order to check if it functions properly now). – Joshua Eworo Nov 21 '20 at 07:27
  • You don't need to delete it because it'll be reassigned, and generally deleting a primitive variable is a bit wonky. For `===` vs `==`, this is a good link: https://stackoverflow.com/questions/359494/which-equals-operator-vs-should-be-used-in-javascript-comparisons – holtc Nov 21 '20 at 07:29
  • Ah, I meant to type "shouldn't" in my comment. Thanks for the clarification, and I will be sure to read through the thread. – Joshua Eworo Nov 21 '20 at 07:37