Start learning free

LESSON 126 OF 348 · LOOPS & CONDITIONALS

Even Numbers From Array: Buggy Code in Scala in Scala

Practice

Inside the code editor we've tried to write a function that takes an array nums as argument and prints to the console the even numbers from that array.

So when we called printEvenNumbers(Array(2, 1, 0, 4, 3)), we expected our code to print:

2
0
4

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

even
even

Assignment:

Your task is to fix our function such that it prints the even numbers from the array.

STEP 1 OF 1
    Ctrl + Enter to check

    Buggy Code Print Even Numbers in Scala

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