This Question is not duplicate
I trying to create a bool Function in javascript
but the bool is not working, it always gives me true
this code is loading the id of youtube videos and see if it exists in youtube by checking image availabality.
function CheckPic() {
var TheVideoID = document.getElementsByClassName('VI');
const Images = [];
for (var i = 0; i < TheVideoID.length; i++) {
getMeta('http://img.youtube.com/vi/' + TheVideoID[i] + '/mqdefault.jpg', (err, img) => {
Images[i] = img.naturalWidth;
});
}
alert(Images.length);
for (var i = 0; i < Images.length; i++) {
if (Images[i] == 120) {
return false;
}
}
return true;
}
using like this
if (CheckPic())
{
}