So I have a task to create a object method named toggleCheckOutStatus
that changes the value saved to the _isCheckedOut
property.
If the value is of _isCheckedOut is true
, then change it to false
. If the value is false
, then change it to true.
The correct soution for thiss was:
toogleCheckOutStatus() {
this._isCheckedOut = !this._isCheckedOut;
}
I understand the code but I want to write the method in different way using if…else:
toggleCheckOutStatus(){
if(this.isCheckedOut = true){
this.isCheckedOut = false;
} else {
this.isCheckedOut = true;
}
}```
The above code is simply not working, when I call the method on object the properties doesn't change. Did I go wrong in the code or what?
Thanks in advance!