Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug - 04_removeFromArray: missing test case #271

Open
3 tasks done
Sarthak-Malla opened this issue Aug 23, 2022 · 5 comments
Open
3 tasks done

Bug - 04_removeFromArray: missing test case #271

Sarthak-Malla opened this issue Aug 23, 2022 · 5 comments
Assignees
Labels
Status: Awaiting Response Waiting for a response from the contributor Type: Bug Involves something that isn't working as intended

Comments

@Sarthak-Malla
Copy link

Sarthak-Malla commented Aug 23, 2022

Complete the following REQUIRED checkboxes:

  • I have thoroughly read and understand The Odin Project Contributing Guide
  • The title of this issue follows the Bug - location of bug: brief description of bug format, e.g. Bug - Exercises: File type incorrect for all test files

The following checkbox is OPTIONAL:

  • I would like to be assigned this issue to work on it

1. Description of the Bug:

The testing for the solution has a missing test case that looks into if all the elements in the Array that matches the element to be deleted is properly deleted.

In other words, the Array from which the elements are supposed to be deleted from has no repeating values. So, the test case does not directly prompt the user to write code that deletes all the instances of the element that is supposed to be deleted from the Array.

2. How To Reproduce:

  • Write the code that satisfies all the 7 cases in the 04_removeFromArray exercise.
  • Open the `removeFromArray.spec.js` file and modify the 5th test case such that the initial array has [1, 2, 2, 3, 4]
  • Run the code again.

3. Expected Behavior:

If the code written does not account for repeated values like the one below, the modified test case (5th test case) results to a failure.

const removeFromArray = function(...arg) {
    const arr = arg[0];
    arg.splice(0,1);

    for (let i = 0; i < arg.length; i++) {
        for (let j = 0; j < arr.length; j++) {
            if (arg[i] === arr[j]) {
                arr.splice(j, 1);
                // j--;
            }
        }
    }

    return arr;
};

Note: Line 9 is commented such that the test case is not matched!

4. Desktop/Device:

  • Device:
  • OS:
  • Browser:
  • Version:

5. Additional Information:

@Sarthak-Malla Sarthak-Malla added Status: Needs Review This issue/PR needs an initial or additional review Type: Bug Involves something that isn't working as intended labels Aug 23, 2022
@thatblindgeye
Copy link
Contributor

@Sarthak-Malla would you still be interested in working on this?

@thatblindgeye thatblindgeye added Status: Awaiting Response Waiting for a response from the contributor and removed Status: Needs Review This issue/PR needs an initial or additional review labels Feb 4, 2024
@Sarthak-Malla
Copy link
Author

@Sarthak-Malla would you still be interested in working on this?

Hey, i would love to. How should I proceed?

@thatblindgeye
Copy link
Contributor

@Sarthak-Malla We'd need a new test added to both the removeFromArray.spec.js file as well as the solution's removeFromArray-solution.spec.js file. For the normal spec.js file the test should be skipped. We could just copy+paste one of the existing tests and tweak it to something like:

test.skip('removes all instances of a value', () => {
  expect(removeFromArray([1, 2, 2, 3], 2)).toEqual([1, 3]);
});

Or however you think makes sense to write the test.

@thatblindgeye
Copy link
Contributor

@Sarthak-Malla just checking in on the status of this

@Sarthak-Malla
Copy link
Author

@thatblindgeye Hey, I am really sorry. I am caught in load of work, is it possible to re-assign this to someone else?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Awaiting Response Waiting for a response from the contributor Type: Bug Involves something that isn't working as intended
Projects
None yet
Development

No branches or pull requests

2 participants