Modify an array

I need a bit of help, I have the following, I want check how many arrays there are, in this case [4] delete the last one ie number 3 , then I want to add 2 more arrays to the bottom, so next time around there will be [5] arrays, delete the last one ie number 4 , then I want to add 2 more arrays to the bottom, and so on. I spent most of the afternoon yesterday trying to achieve this but without success, help would be appreciated thanks.

msg.payload : Object
object
name: "current_temp"
points: array[4]
0: object
x: "00:00"
y: 18
1: object
x: "03:00"
y: 18
2: object
x: "17:02"
y: 21.5
3: object
x: "23:59"
y: 18

I want to add 2 more arrays

Your payload is 1 array with 4 objects.

You can use a function node to manipulate the elements in the array:

array = [{x: "00:00",y: 18},{x: "03:00",y: 18},{x: "17:02",y: 21.5},{x: "23:59",y: 18}]
node.send({text:"full array",payload:array})


// remove last element from array
array.pop()
node.send({text:"last removed",payload:array})

// add element to the end of the array
array.push({x: "14:02",y: 16})
node.send({text:"new element added",payload:array})

// add another element to the end of the array
array.push({x: "16:30",y: 16})
node.send({text:"another element added",payload:array})

example flow

[{"id":"495583a5.7458dc","type":"inject","z":"1971ca29.c484de","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":468,"y":240,"wires":[["39988e91.989fd2"]]},{"id":"39988e91.989fd2","type":"function","z":"1971ca29.c484de","name":"","func":"array = [{x: \"00:00\",y: 18},{x: \"03:00\",y: 18},{x: \"17:02\",y: 21.5},{x: \"23:59\",y: 18}]\nnode.send({text:\"full array\",payload:array})\n\n\n// remove last element from array\narray.pop()\nnode.send({text:\"last removed\",payload:array})\n\n// add element to the end of the array\n\narray.push({x: \"14:02\",y: 16})\nnode.send({text:\"new element added\",payload:array})\n\n// add another element to the end of the array\narray.push({x: \"16:30\",y: 16})\nnode.send({text:\"another element added\",payload:array})","outputs":1,"noerr":0,"x":602,"y":240,"wires":[["378802c0.36f926"]]},{"id":"378802c0.36f926","type":"debug","z":"1971ca29.c484de","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":722,"y":240,"wires":[]}]

This page give an intro to javascript arrays and lists all the array modifiers
You can then use a function node to achieve what you want

Thanks @bakman2 after your flow inspired me, I finally have it working, I had been trying JavaScript array manipulation but could not get past stuff like: 'pop() is not a function' errors anyway its working great now thanks