lua morse code converter

Run Settings
LanguageLua
Language Version
Run Command
input = "balls" local morseCode = { -- letters A = ".-", B = "-...", C = "-.-.", D = "-..", E = ".", F = "..-.", G = "--.", H = "....", I = "..", J = ".---", K = "-.-", L = ".-..", M = "--", N = "-.", O = "---", P = ".--.", Q = "--.-", R = ".-.", S = "...", T = "-", U = "..-", V = "...-", W = ".--", X = "-..-", Y = "-.--", Z = "--..", -- numbers ["1"] = ".----", ["2"] = "..---", ["3"] = "...--", ["4"] = "....-", ["5"] = ".....", ["6"] = "-....", ["7"] = "--...", ["8"] = "---..", ["9"] = "----.", ["0"] = "-----", -- space [" "] = "/" } local result = {} local text = string.upper(input) for i = 1, #text do local char = text:sub(i, i) local morse = morseCode[char] if morse then table.insert(result, morse) else table.insert(result, "?") end end print(table.concat(result, " "))
Editor Settings
Theme
Key bindings
Full width
Lines