I am trying to use an OR operator and the main thing is no matter which one is true (the first or second one). The codes should not be executed.
function addSingleToAlbum(id, single) {
let album = new Item(id, single);
// check duplicates by iterating
for (let i in favorite) {
console.log(song);
console.log('song.length ' + song.length);
console.log('song[i].id !== id ' + song[i].id !== id);
if(song.length < 5 || song[i].id !== id ) {
if(song === null) {
song = [];
}
song.push(album);
break;
}
console.log('id is the same and length is bigger than 5');
}
So in other words if the song length is bigger than 5 or if the song id is the sameā¦the push method should not be executed.