I am a beginner programming student and I have some doubts about how to focus and understand this exercise.
Anyone could explain me the logical to face this exercise?
I have an array like this:
['Queen', 'Elizabeth', 'Of Hearts', 'Beyonce']
and I want this result:
{ Queen : 'Beyonce' }
I want to make function to return the following:
function transformFirstAndLast(array) {
for (var key in array) {
for (var i = 0; i < array.length; i++) {
Object.key[0]
}
}
}
let data = ['Queen', 'Elizabeth', 'Of Hearts', 'Beyonce'] ;
let myobj={}
myobj[data.shift()] = data.pop();
console.log(myobj);