Recap - Simple Calculations
Part of the Fundamentals section of Coddy's Lua journey — lesson 17 of 90.
Challenge
EasyCalculate the total damage from two different attacks and create a battle log message. You'll need to perform arithmetic calculations and then use string concatenation to format the results into a descriptive message.
Create the following variables:
fireAttackwith the value32iceAttackwith the value28
Calculate the total damage by adding these two attack values together and store the result in a variable called totalDamage. Then create a battle log message by concatenating the string "Battle Report: " with totalDamage and the string " damage dealt!". Store this complete message in a variable called battleLog and print it.
Try it yourself
-- Create the attack variables
-- TODO: Write your code here
-- Print the battle log
print(battleLog)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