juan field
asked on
how can i turn the array into an object
// This is what i have so far:
// my output is supposed to be this :
//{
//Queen : 'Beyonce'
//}
function transformFirstAndLast(arra y) {
var result = {};
result = array[0] + " : " + array.pop();
for(var key in result){
key = array[0];
}
return result;
}
console.log(transformFirst AndLast([' Queen', 'Elizabeth', 'Of Hearts', 'Beyonce']));
// my output is supposed to be this :
//{
//Queen : 'Beyonce'
//}
function transformFirstAndLast(arra
var result = {};
result = array[0] + " : " + array.pop();
for(var key in result){
key = array[0];
}
return result;
}
console.log(transformFirst
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
//ok, got it :
function transform(myArray) {
var result = {};
result[myArray[0] ] = myArray.pop();
return result;
}
console.log(transform(['Qu een', 'Elizabeth', 'Of Hearts', 'Beyonce']));
// thank you zephyr_hex (Megan)
function transform(myArray) {
var result = {};
result[myArray[0] ] = myArray.pop();
return result;
}
console.log(transform(['Qu
// thank you zephyr_hex (Megan)
ASKER
thank you zephyr_hex (Megan)
ASKER
//{
//Queen : 'Beyonce'
//}
// is it possible?