Simple implementation
This implementation uses a for loop with a range and string concatenation:How to run
Save the code to a file calledfizzbuzz.walrus and run it:
Expected output
Function-based implementation
You can also implement FizzBuzz as a reusable function that returns a string:Output
Key concepts
- Ranges:
1..101creates a range from 1 to 100 (exclusive end) - Modulo operator:
%checks for divisibility - String concatenation:
+=appends to strings - Type flexibility: Variables can hold different types (string or integer)