Module:Test: Difference between revisions

From Roat Pkz
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
-- This is a Lua module for MediaWiki
-- It provides functionality to calculate percentages of a number
-- Create a table to hold the functions
-- Create a table to hold the functions
local Test = {}
local Test = {}
Line 18: Line 15:
     table.insert(percentages, number * 1.30)
     table.insert(percentages, number * 1.30)
      
      
     return percentages
    -- Format the result as a string
    local resultString = ""
    for i, value in ipairs(percentages) do
        resultString = resultString .. value
        if i < #percentages then
            resultString = resultString .. ", "
        end
    end
   
     return resultString
end
end


-- Export the module
-- Export the module
return Test
return Test

Revision as of 22:44, 3 April 2024

Documentation for this module may be created at Module:Test/doc

-- Create a table to hold the functions
local Test = {}

-- Function to calculate percentages
function Test.calculatePercentages(args)
    local number = tonumber(args[1]) or 0 -- Extract the number from the table
    local percentages = {}
    -- Original number
    table.insert(percentages, number)
    -- 10% increase
    table.insert(percentages, number * 1.10)
    -- 20% increase
    table.insert(percentages, number * 1.20)
    -- 30% increase
    table.insert(percentages, number * 1.30)
    
    -- Format the result as a string
    local resultString = ""
    for i, value in ipairs(percentages) do
        resultString = resultString .. value
        if i < #percentages then
            resultString = resultString .. ", "
        end
    end
    
    return resultString
end

-- Export the module
return Test