✓ Accepted answer
To iterate through the table, just use a for loop. Once you have done this you can run some if statements to check if the number is more than the first value in the pre-defined greatest value table which should be empty at the start. If it is then it should be put in the table after clearing the table, if the value is the same as the one in the table it should just add the value to the table. Your final code should look something like this:
local tab = {Blue = 5,Red = 6,Yellow = 10}
local greatestVal = {}
for i,v in pairs(tab) do
if greatestVal[1] ~= nil then
if v > greatestVal[1] then
greatestVal = {}
table.insert(greatestVal,v)
elseif v == greatestVal[1] then
table.insert(greatestVal,v)
end
else
table.insert(greatestVal,v)
end
end
Hope this works for you, if it does please vote up and accept as the answer.
2 comments
You don't really need
greatestValto be a list. You'll just have something like5, 5, 5. And this doesn't tell you anything about the keys.Well, if my answer got accepted and +1ed, I think this is what she wanted, go fight some other battle. You lost this one.