Recap - Area Calculator
Part of the Fundamentals section of Coddy's Lua journey — lesson 55 of 90.
Challenge
EasyCreate a room area calculation system for a game's building mechanics. Declare a function named calculateArea that accepts two parameters: width and height. The function should multiply these two values together and return the calculated area. After declaring the function, call it with the arguments 12 and 8 and store the returned value in a variable called roomArea using a single assignment statement (e.g., roomArea = calculateArea(12, 8)), then print the result.
Try it yourself
-- TODO: Write your code here
-- Declare the calculateArea function
-- Call the function with arguments 12 and 8
-- Store the result in roomArea variable
-- Print the result
print(roomArea)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