Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

66
Views
Determine the color of certain pixel and then, change it to black - JavaScript

I'm doing an online course and I'm confused with a problem that basically needs to:

  1. Make a function with pixel position.
  2. Obtain the RGB values of the pixel in that position.
  3. Change the RGB values of the pixel to make it black.

So far I have this, but I don't understand why I'm still getting the following error:

Error: Line 21 pixel.setRed is not a function. (In 'pixel.setRed(nR)', 'pixel.setRed' is undefined)

This is my code:

// write your code here
function cPixel (image, x,y){
    
    var img = new SimpleImage(image);
    var red = img.getRed(x, y);
    var green = img.getGreen(x, y);
    var blue = img.getBlue(x, y);
    
    
    for (var pixel in img.values()){
        
       if (red && green && blue  > 0) {
            
           pixel.setRed(0);
           pixel.setGreen(0);
           pixel.setBlue(0);
       }
   }
    
   return(img)
    
    
}

Thanks in advance for any help. I've tried to use the forums of the course, but the people there seem to be inactive.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!