Creates
<select>
element using
document.createElement
method and fills with JSON array
optionArray = [
"daily",
"weekly",
"biweekly",
"monthly"
];
// Creates <select> element
let selector = document.createElement('select');
for(let option in optionArray) {
let value = optionArray[option];
// Creates <option> element for <select>
let newOption = document.createElement("option");
newOption.value = value;
newOption.innerHTML = value;
selector.options.add(newOption);
}
// Adds the <select> element into the document object
document.body.appendChild(selector);