kebabcase

function kebabcase( strlst ) --> str

Description

Concatenate the assigned words in the array table to a kebab case string.

Parameters

strlst

An array table with strings.

Return Values

str

The generated kebab case string.

Code

--ZFUNC-kebabcase-v1
local function kebabcase( strlst ) --> str
   local str = {}
   for i, v in ipairs( strlst ) do
      table.insert( str, string.lower( v ) )
   end
   return table.concat( str, "-" )
end

return kebabcase

Examples

local t = require( "tapered" )
local kebabcase = require( "kebabcase" )

t.is( "wiki-word-bumpy-caps", kebabcase{ "Wiki", "Word", "BUMPY", "caPS" } )

t.done()

Inspired by

See also