First steps · 4 / 69
Find complete batches
YOUR TASK
Make this happen
The remainder operator % reports what is left after division. A batch is complete when its quantity divides evenly by the batch size.
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
exports.complete = function(quantity: number, size: number): boolean return false end
lesson.test.lua
local t = require("test")
local subject = require("cococo.subject")
t.it("complete batch", function()
local s = subject.load()
t.expect(s.complete(12, 4)):eq(true)
end)
t.it("partial batch", function()
local s = subject.load()
t.expect(s.complete(13, 4)):eq(false)
end)
t.it("empty batch", function()
local s = subject.load()
t.expect(s.complete(0, 4)):eq(true)
end)