Working with data · 20 / 69
Normalise a code
YOUR TASK
Make this happen
Normalisation reduces accidental differences in input. Convert an ASCII product code to uppercase using the string library.
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.normalise = function(code: string): string return code end
lesson.test.lua
local t = require("test")
local subject = require("cococo.subject")
t.it("mixed case", function()
local s = subject.load()
t.expect(s.normalise("Ab-12")):eq("AB-12")
end)
t.it("already uppercase", function()
local s = subject.load()
t.expect(s.normalise("AB")):eq("AB")
end)