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:
- the first element of the array as the object's key
- the last element of the array as that key's value. I am doing a var key in array and then a loop through the array
function transformFirstAndLast(array) {
for (var key in array) {
for (var i = 0; i < array.length; i++) {
Object.key[0]
}
}
}