Start learning free

LESSON 128 OF 349 · LOOPS & CONDITIONALS

Print Odd Numbers: Buggy Code in Swift in Swift

Practice

Inside the code editor we've tried to write a function that takes a number n as argument and prints to the console the odd numbers from 0 through n.

So when we called printOddNumbers(8), we expected our code to print:

1
3
5
7

but it seems like we made some mistakes because when we run our code, it prints nothing.


Assignment:

Your task is to fix our function such that it prints the odd numbers from 0 through n.

STEP 1 OF 1
    Ctrl + Enter to check

    Buggy Code Print Odd Numbers in Swift

    Keep going with SwiftAbout 340 step-by-step lessons, from your first line of code to coding interviews. Free to start.
    Start learning free