If you're seeing this message, it means we're having trouble loading external resources on our website.

If you're behind a web filter, please make sure that the domains *.kastatic.org and *.kasandbox.org are unblocked.

Computer programming

Unit 1: Lesson 8

Bonus: Resizing with variables

Using variable expressions

Problem

This program draws a rectangle based on the variables w (for width) and h (for height):
var w = 10;
var h = 50;
rect(200, 200, w, h);
Let's say we want to make h dependent on w, so that if we ever change the value of w, the value of h will change proportionately, so that h is always 5 times as large as w. What expression should h hold?