I am stuck on a piece of code and I can quite figure out how to finish one part of this function. This is what I have so far:
const usersTestArray = [
{id: "1", name: "Joe Graham", option: "option1"},
{id: "2", name: "Kyle Howell", option: "option2"},
{id:"3", name: "Lucy Bauch", option: "option3"},
{id: "4", name: "Sammie Lebsack", option: "option4"}
]
const createSelectOptions = (usersTestArray) => {
if(!usersTestArray){
return undefined
}
return userTestArray.map((x) => x.option)
}
Most of this is correct, however, in the function above, I need to add a create an option element for each user in the array with document.createElement(). I then need to assign the user.id to option.value and the user.name to option.textContent. then it is supposed to return an array of option elements.