Practice · 2 of 5
Build output in a loop
CHALLENGE
Difficulty: beginner+25 XP
Implement String evens(int n): return the even numbers 2, 4, ..., 2n joined by ", " — e.g. evens(3) returns "2, 4, 6". Accumulate into a String; add ", " **before** each item except the first.
Press Submit to check your solution.
Back to lesson: Practice: Loop rep