Skip to content

Instantly share code, notes, and snippets.

@arisawali2014
Last active June 23, 2021 04:29
Show Gist options
  • Select an option

  • Save arisawali2014/4be5e7379b591f91718dfbe420ff449f to your computer and use it in GitHub Desktop.

Select an option

Save arisawali2014/4be5e7379b591f91718dfbe420ff449f to your computer and use it in GitHub Desktop.

Revisions

  1. arisawali2014 revised this gist Jun 23, 2021. No changes.
  2. arisawali2014 revised this gist Jun 23, 2021. No changes.
  3. arisawali2014 created this gist Jun 23, 2021.
    21 changes: 21 additions & 0 deletions removeNode.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    var data = [
    {id: "1", name: "Snatch", type: "crime"},
    {id: "2", name: "Witches of Eastwick", type: "comedy"},
    {id: "3", name: "X-Men", type: "action"},
    {id: "4", name: "Ordinary People", type: "drama"},
    {id: "5", name: "Billy Elliot", type: "drama"},
    {id: "6", name: "Toy Story", type: "children"}
    ];

    function RemoveNode(id) {
    return data.filter(function(emp) {
    if (emp.id == id) {
    return false;
    }
    return true;
    });
    }

    var newData = RemoveNode("1");

    document.write(JSON.stringify(newData, 0, 4));