Varrience well... the last one i wrote was pseudo code so it won't actually run so if your looking for something to play around with and understand how it works this is the better example of what i was showing off.... not sure if i should remove the previous post though
var obj = {
pro: true,
noob: false,
achivements: 1,
total: 15
}
// we can then update it at any time a new achievement is unlocked
var loser = true;
if(loser && !obj.noob){obj.noob = true; obj.achivements++}
console.log("you have "+(obj.total-obj.achivements)+" left keep it up!")
// the second way is below here which is basically what Ack did
var accomp = [
{title: "Ruiner", unlocked: false},
{title: "Participation Award", unlocked: false},
{title: "Secret Customer", unlocked: true}
];
// to calculate how many achievements we have left we must iterate through the Array
function accompLeft(){
var left = accomp.length; // stores total achievements
for(var i = 0; i < accomp.length; i++){
if(accomp[i].unlocked){left--} // here we access an accomp [ index ] and a .property value from that index
}
return(left)
}
console.log("you have "+accompLeft()+" left keep it up!")