I am trying to get the first and last item in array and display them in an object.
What i did is that I use the first and last function and then assign the first ite
ES6
var objOutput = { [myArray[0]]: [...myArray].pop() }
var myArray = ['Rodel', 'Mike', 'Ronnie', 'Betus']; var objOutput = { [myArray[0]]: [...myArray].pop() } console.log(objOutput);