I'm making a simple quiz game and I'm having some trouble with calculating the results. The problem is really simple, I need to find out how to say if clicked1
has a value more than the whole dictionary it is in then do this function. Here is the code for the dictionary and the function I'm trying to make. Also, if someone could explain why possibilities.value
doesn't work for my problem that would be much appreciated.
var possibilities = {
'clicked1': 0,
'clicked2': 0,
'clicked3': 0,
'clicked4': 0,
};
function results(){
if (possibilities['clicked1'] > possibilities){
console.log("it worked");
}
};
Just iterate through Object.values
with every
:
var possibilities = {
'clicked1': 0,
'clicked2': 0,
'clicked3': 0,
'clicked4': 0,
};
if (Object.values(possibilities).every(val => possibilities.clicked1 >= val || val == possibilities.clicked1)) {
console.log("It works!");
}
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments