Recap - Format Username
Part of the Fundamentals section of Coddy's Lua journey — lesson 49 of 90.
Challenge
EasyCreate a username processing system that standardizes and shortens usernames for display purposes. Declare a variable called rawUsername and assign it the value "GameMaster2024". First, use string.lower() to convert the entire username to lowercase and store the result in a variable called lowercaseUsername. Then, use string.sub() to extract the first 5 characters from the lowercase username and store this shortened version in a variable called displayUsername. Print the final display username.
Try it yourself
-- Declare the rawUsername variable
local rawUsername = "GameMaster2024"
-- TODO: Write your code here
-- Convert to lowercase and store in lowercaseUsername
-- Extract first 5 characters and store in displayUsername
-- Print the final display username
print(displayUsername)All lessons in Fundamentals
4Operators 2 Relational & Logic
Equality OperatorsRelational OperatorsThe 'and' OperatorThe 'or' OperatorThe 'not' OperatorShort-Circuit EvaluationTruthy and Falsy ValuesRecap - Simple Logic7Basic Conditional Logic
The if-then StatementThe if-then-else StatementThe elseif StatementRecap - Treasure Chest2Variables and Data Types
What is a Variable?NumbersStringsBooleansThe Value 'nil'The type() FunctionNaming ConventionsRecap - Character Profile5Basic Output
Printing LiteralsPrinting VariablesPrinting Multiple ValuesCombining Strings & VariablesThe tostring() FunctionInputCastRecap - Status ReportRecap - Till 1208String Manipulation Basics
string.len()string.upper & string.lowerstring.sub()string.rep()string.find()Recap - Format Username3Operators 1 Arithmetic & Conc
Arithmetic OperatorsModulo OperatorExponentiation OperatorString ConcatenationOperator PrecedenceRecap - Simple Calculations6Project: Character Stats Disp
Welcome MessageDeclare Character Stats9Functions Basics
Declaring a FunctionCalling a FunctionFunctions with ParametersFunctions with Multiple ParamsThe 'return' StatementRecap - Area Calculator