Recap - Repeating Actions
Part of the Fundamentals section of Coddy's GO journey — lesson 50 of 109.
Challenge
EasyComplete the code to implement different types of loops and print the results.
Try it yourself
package main
import "fmt"
func main() {
// TODO: Write a for loop that prints numbers from 1 to 5
// Each number should be on its own line
// TODO: Print a blank line for separation
// TODO: Write a for loop that calculates the sum of numbers from 1 to 5
// Store the result in a variable named 'sum'
// After the loop, print "Sum: 15"
// TODO: Print a blank line for separation
// TODO: Write a for loop that starts at 10 and counts down to 1
// Each number should be on its own line
}All lessons in Fundamentals
4Comparison & Logical Operators
Comparison Operators - Part 1Comparison Operators - Part 2Logical AND OperatorLogical OR OperatorLogical NOT OperatorOperator Precedence BasicsRecap - Making Comparisons7Control Flow: Loops
What The `for` Loop ExplainedFor Loop - BasicFor Loop - Condition OnlyThe `break` KeywordThe `continue` KeywordNested LoopsRecap - Repeating Actions2Variables and Basic Data Types
What is a variableType Inference with `:=`Integers (int)Floating-Point NumbersBooleansStringsZero ValuesConstantsNaming ConventionsRecap - Variables and Types5Basic Input/Output
Formatted OutputFormat VerbsPrinting TypesGetting Basic User InputRecap - Input and Output8Functions
Understanding FunctionsDeclaring a FunctionCalling FunctionsFunction ParametersReturning a Single ValueReturning Multiple ValuesNamed Return ValuesFunction Scope BasicsRecap - Creating Reusable Code3Basic Operators
Arithmetic OperatorsDivision OperatorThe Modulo OperatorAssignment OperatorAugmented Assignment OperatorsIncrement and DecrementRecap - Calculations6Control Flow: Conditionals
The `if` StatementThe `else` KeywordThe `else if` KeywordVariable Shadowing in `if`Initializing VariablesThe `switch` StatementSwitch with ExpressionsSwitch without ExpressionThe `fallthrough` KeywordRecap - Making Decisions