External Project Contribution
Tags: opensource, javascript, github, beginners
Published: 2021-11-19 19:56:30

With the coming of __November 1st__, we had our third assignment -- __Release 0.3__ in OSD600. In this release 0.3, there are __3__ different requirements. And the first one is about __External Project Contribution.__ 
For this external project contribution, I selected a repository that I worked with in __Release 0.2__. It called [__help.js__](https://github.com/TogaTech/helpful.js).

This time, I worked at the issue about __adding a testing method for objects__. "_We should have a method that finds the difference of two objects (any keys that are present in the second object are removed from the first)_".
![Issue](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5c13b0wgpsvqrf2xzdda.png)

###Procedure 
Due to I __forked__ this repository to my Giuhub account for my Release 0.2. I just need to __pull all the new commits__ that the origin repository made recently with the command `git pull origin main`. And then I started to add a new test function based on the issue. 

At the beginning, I got stuck at "_How can I get the keys from an object?"_. Therefore, I googled the solution from __StackOverFlow__.
There are some tips and ideas helped me to get the keys from an object. I used the method `Object.keys()` and store it to an `array`.
```
	let array1 = Object.keys(object1);
```
And then I just used __for loop__ to figure out whether there are some keys that present in the first object and the second object at the same time. __If so__, I just need to remove them from the first object. However, there was one more issue comes up at that timing -- "_How do I remove those keys from the first object?_" So, I searched the recommend ways on google again. And I found that I can use the word `delete` to do that.
```
	delete object1[array1[i]]; 
```
This code allows me to delete the keys in an object. And then I just add some test logic to the `test.js`. 
__While I testing my code__, I realized that my code would __delete__ the keys from an object __permanently__. And I don't think that's a good practice for any programmer. __Therefore__, I tried to add a `temporary object` to my function, and let the temporary object equals to the first input object. Then I could delete keys from the temporary object so that it will not affect the original first input object.
__Surprisingly__, this logic didn't work as I expected. It does delete keys from  the temporary object, but it also deletes keys from the first input object! So, I just use an object that with same keys values again and again:
![test_function](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/t3fiubqx80jx16tstkyz.png)

After I made the tests run successfully, I read through the testing code in the program again. And I found out that I was using a __different format__, which is a __bad practice__ when you are trying to help improve a program that you didn't make it. So, I just audit my code with the same format as they did.
![PR_code](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/iohimbnd96v2etmssz3v.png)

###My feelings
__Honestly__, this is a __more challenged__ issue for me. __First of all__, I don't familiar with working on object in JavaScript. __Second of all__, I don't have that much experience with contributing on Github. __Last but no least__, I messed up the coding procedure at the beginning which is a really bad practice. I should read through the code before I do any coding stuff.
__Anyway__, this is a __helpful__ project for me. I learned how to get all the keys from an object and how to delete them. Also, I have more experience to contribute on __Github__!

Lind to the Repo I worked: [[Helpful.js]](https://github.com/DerekJxy/helpful.js)