How to add an array to the last in this object:
const formElment = document.querySelector(".form");
formElment.addEventListener("submit", (event) => {
event.preventDefault();
var array = [];
var checkboxes = document.querySelectorAll("input[type=checkbox]:checked");
for (var i = 0; i < checkboxes.length; i++) {
array.push(checkboxes[i].value);
console.log(checkboxes[i].id);
}
const formData = new FormData(formElment);
const data = Object.fromEntries(formData);
console.log(data);
});
I used eventlistner
for get form data and checkbox=checked. So now I want add those selected checkbox id to the end of the object and send through an API.