Before we dive into the specific CodeHS answers, let's understand the science. RGB stands for Red, Green, Blue. Unlike mixing paint (where combining all colors makes black), digital screens use additive color mixing. This means:
Every color you see on a monitor is a combination of these three channels, each ranging from 0 to 255.
The Problem: "Write the RGB for a medium gray that is exactly 40% white."
The Calculation: 40% of 255 = 102.
The Answer: rgb(102, 102, 102) exploring rgb color codes codehs answers best
To make yellow → Red + Green (255, 255, 0)
To make purple → Red + Blue (255, 0, 255)
To make orange → Red + some green (255, 165, 0)
Prompt: Write a program that lets the user change RGB sliders and displays the resulting color. Before we dive into the specific CodeHS answers,
Best solution structure (JavaScript + Graphics):
function start() var redSlider = new Slider(0, 255, 0); var greenSlider = new Slider(0, 255, 0); var blueSlider = new Slider(0, 255, 0);var colorRect = new Rectangle(200, 200); colorRect.setPosition(100, 100); add(colorRect); function updateColor() var r = redSlider.getValue(); var g = greenSlider.getValue(); var b = blueSlider.getValue(); colorRect.setColor(Color.rgb(r, g, b)); redSlider.onChange(updateColor); greenSlider.onChange(updateColor); blueSlider.onChange(updateColor);
Key insight: Always link onChange events to a single update function to avoid code duplication. Every color you see on a monitor is
For students looking to ace the "Challenge" or "Custom" problems, here are the specific answers for high-difficulty RGB questions often found in CodeHS units 5.2 or 7.3.