Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

69
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda