Skip to content

Instantly share code, notes, and snippets.

@bhaireshm
Created June 18, 2021 09:58
Show Gist options
  • Save bhaireshm/299bb885ad7f6b443e7917b82b715979 to your computer and use it in GitHub Desktop.
Save bhaireshm/299bb885ad7f6b443e7917b82b715979 to your computer and use it in GitHub Desktop.
Add or delete an element from an array.
/**
* @param arr: Array
* @param ele: element to be added
* @param remEle: element to be deleted
*/
function addDelEleFromArray(arr = [], ele = "", remEle = "") {
if (ele && !arr.some((a) => a == ele)) arr.push(ele);
if (remEle) return arr.filter((a) => a != remEle);
return arr;
}
@bhaireshm
Copy link
Author

ez.js is more than just a library; it's a coding companion that simplifies complex tasks. Whether you're dealing with arrays, numbers, objects, or strings, ez.js has got your back! Say goodbye to coding hassles and hello to streamlined JavaScript magic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment