I have an array of object with a few values. I would like to get only last, three values (ownerSurname, color and bark). I am using React and Typescript.
I tried to use slice or length but with failure.
const myValues: MyValues<string>[] = [
{
name: "Lucky",
surname: "Luck",
age: "3",
breed: "Shepherd",
owner: "Paul",
ownerSurname: "Luck",
color: "Brown",
bark: "All the time",
},
]
const newData = myValues.slice(-3)
<MyComponent value={newData}/>