Functions and modules · 26 / 69
Use a supplied module
YOUR TASK
Make this happen
require loads a named module. In the academy, modules are explicit in-memory files; missing modules are never fetched from the network. Use the supplied units helper to convert metres to millimetres.
Read the cases in
lesson.test.lua, then choose Check solution to see what needs to change.Update
subject.luauntil every test passes. Keep the supplied tests unchanged.
Read the starter and tests
subject.lua
local units = require("units")
exports.convert = function(metres: number): number
return metres
end
lesson.test.lua
local t = require("test")
local subject = require("cococo.subject")
t.it("uses helper", function()
local s = subject.load()
t.expect(s.convert(2.5)):eq(2500)
end)