Search
In the example given below, user2 does not have the property noOfAttempts, which causes an unwanted output when totalNoOfAttempts - user2.noOfAttempts is executed.
user2
noOfAttempts
totalNoOfAttempts - user2.noOfAttempts
Use the ?? operator to use the default value of the noOfAttempts as 0.
??
0