Hi,
I’m trying to see if a table contains a specific element. The following doesn’t work and I can’t figure out why.
It prints “horse” 3 times, so I know it’s counting the number of elements correctly and the value I want to test is being passed, but I get a “nope” rather than a “yes”
local theList = {"dog","cat","horse"} local function checkTheList(theList, val) for k,v in pairs(theList) do print(val) if k == val then return true end end return false end if checkTheList(theList, "horse") then print("yes") else print("nope") end