Hello, I’m taking AP computer science principles and they are teaching us tables in javascript.
They had this pretty cool function, table.join()
How it works is you put the name of the table following by “.join” and with the parameters of the things you want to seperate the items with. It will return a string of the full table seperated with the thing.
For example
local colors = {"red", "pink", "blue"}
print(colors.join(" and ")
There is not a table.join function on Luau, the closest replacement for your situation is string.format.
Please note that this question can easily be answered by consulting the official Roblox documentation site (found in above hyperlink). Containing the answers to any questions about Luau that may be required.
They aren’t looking to combine two arrays into one, they are looking to concatenate the values of the array into a string divided by " and " as shown here
This exact behavior can be replicated using table.concat.
By the way, that doesn’t work even if the question was about joining tables:
tabA = {"Item", 2, 3}
tabB = {"Something", "Thing", 42}
local joinedTab = {
table.unpack(tabA),
table.unpack(tabB),
}
for i, v in ipairs(joinedTab) do
print(i, v)
end
This can be difficult in this case scenario. I tried checking both Lua documentations and Roblox documentations but I was unable to find a solution. I would never ask a question here unless I wasnt able to figure it out with my available resources. It takes more time to write a post than google it.
In that case, try going less specific, and instead of searching for something pertaining to JS specifically or something similar you could try searching for just the table functions. Doesn’t always work but could be helpful in scenarios like this.