! logic reversal Operator

So i’m just trying to confirm the exclaimation mark infront of the object[id].hasOwnProperty(“tracks”) is there because we want it to return true. But why? I thought it said to only check if the album doesn’t have tracks property which will return false anyway since theres nothing inside tracks. Why then do we need to change it to true?
I don’t think i come across this in the the lesson, this is new to me

  **Your code so far**

// Setup
var collection = {
2548: {
  albumTitle: 'Slippery When Wet',
  artist: 'Bon Jovi',
  tracks: ['Let It Rock', 'You Give Love a Bad Name']
2468: {
  albumTitle: '1999',
  artist: 'Prince',
  tracks: ['1999', 'Little Red Corvette']
1245: {
  artist: 'Robert Palmer',
  tracks: []
5439: {
  albumTitle: 'ABBA Gold'

// Only change code below this line
function updateRecords(object, id, prop, value) {
if(prop !== "tracks" && value !== ""){
  object[id][prop] = value;
}else if(prop === "tracks" && !object[id].hasOwnProperty("tracks")){
  object[id][prop] = [value];
}else if(prop === "tracks" && value !== ""){
}else if(value === ""){
  delete object[id][prop];
return object;

updateRecords(collection, 5439, 'artist', 'ABBA');
  **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36.

Challenge: Record Collection

Link to the challenge:

Check if we want to update the property “tracks” and if yes, then also check if the object to update doesn’t already have a “tracks” property.
Then create a new array with the value to add.

This is the first case.

The second case is updating “tracks”, but already having the “tracks” property, meaning there is already something stored. Then we want to add something additonal to the existing tracks. If we would use the first case, we would overwrite (= lose) the existing values.

i understand that, what i don’t understand is why we would be using logic reverse operator on the object[id].hasOwnproperty?
As i understand it will return false if we don’t use the this ! isn’t that what we wanted for it to check for tracks property and find out that there is no value in there hence being false. why then would we want it to be true by using the !


hasOwnProperty returns true if the object has the property and false if it does not.

oh so the && is the reason why we are using the ! logic reverse operator on the object[id].hasOwproperty? is it because both sides need to be true when using && ?
Oh soo what we are trying to do is to get both sides to be true due to && it will check if tracks has a property and usually it returns false cos in this case tracks does not have a property so we using the logic reverse to say if it is found that tracks does not have a property then instead of return false return true,
in a way it is correct to return false but since we are using && we want both side to be true ?? am i correct??

Yes, this specific case runs if the condition is true.
If you have a logical && (AND), each condition has to be true.