Kong response-transformer-advanced plugin

I have written the below code in Config.Transform.Functions (response-transformer-advanced plugin)
I hard coded for element ( data.statements[1])…how can I make dynamic ( data.statements JSON array. Loop through all cardnum in data.statements[ 1…n ]). I tried put lua script loop but the above Kong plugin is not accepting the script. Please help me with looping of the below program which need to executed in Kong.

return function (data)
local s= data.statements[1].cardnum
local x= s:sub(10 )
data.statements[1].cardnum= “********”…x
return data end

By the way , I tried with below code, it gives the below error…If you throw some light, it will be great help: I am not sure where I am wrong. Actually we want to hide credit card number from the output.

Our service Output will look like the below

statements: [ {“name”:“just”, cardnum:“12345678”},{“name”:“just”, “cardnum”:“12345678”} ]

Our team wants like “cardnum”:“*******5678”

code

return function (data)
for index, value in pairs(data.statements) do
local s= (data.statements[index].cardnum):sub(10)
data.statements[index].cardnum= “********”…s
end
return data end

It throws exception

schema violation (config.transform: { functions = { “Error parsing function: /usr/local/share/lua/5.1/kong/tools/kong-lua-sandbox.lua:151: [string "return function (data) …"]:1: ‘=’ or ‘in’ expected near ‘’”, “Error parsing function: /usr/local/share/lua/5.1/kong/tools/kong-lua-sandbox.lua:151: [string "value in pairs(data.statements) do local s= (…"]:1: ‘=’ expected near ‘in’” } })