JSFiddle - React, Tailwind, and code Playground

by John Allan

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/ramda/0.26.1/ramda.js"></script>

JavaScript

const newObj = { id: 'a', value: 'new'};
const isOdd = (n) => n.id === newObj.id;
const oldArray = [{ id: 'a', value: 'old' }, { id: 'b', value: 'old' }];

let newArr = oldArray.filter(i => i.id !== newObj.id).concat([newObj]);


console.log(oldArray);
console.log(newArr);