I’m working on the first week of the Duke Learn to Program coursera course. I’m on the “for loops” section trying to create a simple loop that will first: Create a black 2×2 image using dukes built in “simpleImage” method and second: use a for loop to turn all the pixels in the image yellow. Here is the code I am using below:
var img = new SimpleImage(2,2);
print(img);
for (var pixel of img.values());{
pixel.setRed(255);
pixel.setGreen(255);
pixel.setBlue(0);
}
print(img);
The issue I’m running into using this code, is the final result where of print(img) is simply printing a second black square. My code is either failing to change the pixels, or I’m failing to understand how to display the output. Any help is appreciated!