0

Okay, so I'm trying to remove elements from a number array that match a certain number. I got the correct solution already but I don't entirely understand it.

Here is the code that doesn't work:

The code that doesn't work.

And here is the console output: Console output

It works fine until two numbers beside each other are the same. Note how the ending result of the console output was [3,3]. Even though both of those 3's should have been removed. I read an article discussing the .splice() function. Article

I had trouble understanding what it meant, but the solution it provided was correct. I'm just trying to wrap my head around what goes no when the proceeding number in the array is the same as the current number.

Here is the solution that works: Working solution

  • 2
    Please post code, errors, sample data or textual output here as plain-text, not as images that can be hard to read, can’t be copy-pasted to help test code or use in answers, and are hostile to those who use screen readers. You can edit your question to add the code in the body of your question. Use the `{}` button to format any blocks of code, or indent with four spaces for the same effect. **We can’t run your screenshot as code.** – tadman Jan 08 '18 at 17:42
  • [Why not upload images of code on SO when asking a question?](https://meta.stackoverflow.com/questions/285551/why-not-upload-images-of-code-on-so-when-asking-a-question/285557) – charlietfl Jan 08 '18 at 17:43

0 Answers0