asd.forEach((element) => {
element.addEventListener('click', () => {
// И здесь уже дальнейшая логика
})
})
<form type="submit">
const elements = {
'form': document.querySelector('form'),
'text': document.querySelector('.out-9'),
'input': document.querySelector('.i-9'),
}
elements.form.addEventListener('submit', (event) => {
event.preventDefault();
const data = elements.input.value;
elements.text.innerHTML = data;
elements.form.reset();
});
fetch('https://jsonplaceholder.typicode.com/todos/1').then((data) => console.log(data));
/*
Response {
size: 0,
[Symbol(Body internals)]: {
body: BrotliDecompress { ...
arayOfSheep.forEach((item) => item===true count++1);
const countSheeps = function (arr) {
let counter = 0;
arr.forEach((sheep) => {
counter += sheep === true ? 1 : 0;
});
return counter;
};
const sumValues = (obj) => {
let sum = 0;
const entries = Object.entries(obj); // [[key1, value1], [key2, value2]]
for (const [key, value] of entries) {
sum += typeof value === 'object' ? sumValues(value) : value;
}
return sum;
};
const checkIntoHotel = (hotel, people) => {
let index = 0;
const checkedHotel = hotel.map(({ room }) => room.map(({ id, name }) => {
const {id: parId, name: parName } = people[index];
index += 1;
return { id: parId, name: parName };
}))
return checkedHotel;
};