Selecting the value of an entire dictionary

The Nuthouse

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");
    }
};

Jack Bashford

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.

edited at
0

Comments

0 comments
Login to comment

Related

Selecting Option Based on Value

Selecting random values from dictionary

Selecting List<string> into Dictionary with index

Selecting entire word that includes dashes

selecting records without value

Randomly selecting a value from a dictionary AFTER a key was randomly selected

Selecting the maximum value for each key in a dictionary python

on click of table row it is enableing entire table intead of one row and after selecting getting value undefine

C# Dynamic Dictionary - Selecting Random Value from Dynamic Object

Selecting objects with specific key:value pair from dictionary

Python Code Not Selecting Correct Dictionary

Selecting entire column after searching for header name

Selecting from xml file into a dictionary

XSLT why is this not selecting what I want but selecting the entire xml?

selecting highest value in a table

Selecting items in a dictionary using python

Selecting one value and not the other

Selecting the value of a column not in GroupBy

Subquery Results Differ When Selecting Entire Group

Selecting value of child element

Selecting Dropdown value with onchange

Selecting a random tuple from a dictionary

Selecting the Maximum Value of

Dictionary not selecting correct key

Selecting key and value of dictionary in Azure DocumentDB / Azure CosmosDB

How do you sort a dictionary by key, and return the entire dictionary with both key and value?

MVC 5 - Why is my linq code selecting an entire query instead of a single value?

Selecting rows with a value of False

Selecting single value from dictionary with multiple values per key