data.find(el => el.item === 'geovishap-hatchling') // => {id: 'enemies', item: 'geovishap-hatchling'}
data.find(el => el.item === 'geovishap-hatchling-3') // => undefined
data.findIndex(el => el.item === 'geovishap-hatchling') // => индекс элемента
data.find(el => el.item === 'geovishap-hatchling-3') // => -1
myClients = [];
wss.on('connection', function(ws) {
myClients.push(ws);
});
// сделать 1 функцию
const popupTitle = advertElement.querySelector('.popup_title');
popupTitle.textContent = offer.title;
const poputTitleContent = title => {
const popupTitle = advertElement.querySelector('.popup_title');
popupTitle.textContent = title;
};
function poputTitleContent(title) {
const popupTitle = advertElement.querySelector('.popup_title');
popupTitle.textContent = title;
}
similarOffers.map(({author, offer}) => {
poputTitleContent(offer.title);
// ... остальной код
};
const a = [1, 2, 1, 2, 3, 1, 1, 2, 3];
const d = [];
for (let i = 0; i < a.length; i++) {
a[i] === 1 ? d.push([1]) : d[d.length - 1].push(a[i]);
}
console.log(d); // [ [ 1, 2 ], [ 1, 2, 3 ], [ 1 ], [ 1, 2, 3 ] ]
const a = [1, 2, 1, 2, 3, 1, 1, 2, 3];
const d = [];
a.map(el => {
el === 1 ? d.push([1]) : d[d.length - 1].push(el);
});
console.log(d);
arr.filter(num => ['1','2','5'].includes(num.toString()[0])
<div class="block">
<img src="https://miro.medium.com/max/8452/1*BR2RiTRoYor9xSrzEgxLWQ.jpeg">
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
</div>
img {
position: fixed;
left: 0;
top: 0;
width: 100px;
height: 100px;
}
$(window).on("scroll", function() {
var s = 400 - Math.min(400, $(document).scrollTop());
$("img").width(s).height(s);
});