In the lesson the instructions are to:
Write a function that draws horizontal lines on the graphics canvas. If a line is horizontal, then the y-values for the endpoints are the same. The parameters to your function should be the y location, and the length, and all of your lines should start at x position 0. Your function must be named horizontalLine.
For example if you call:
horizontalLine(100, 200);
you should get a horizontal line of length 200 starting at position (0, 100).
If your start function looks like:
function start(){
horizontalLine(100, 200);
horizontalLine(200, 100);
horizontalLine(300, 20);
}
The ending world should look like this. Now I've gotten my world to look exactly like that but the code check returns wrong. I'm not sure whats wrong with my code but I'm guessing its because it wants me to input two numbers instead of the four in my start function but I can't get it to work. I've been stuck on this for nearly a month and the answer is probably really simple but I can't figure it out, please help.
This is my code:
function start() {
horizontalLine(0, 100, 200, 100);
horizontalLine(0, 200, 100, 200);
horizontalLine(0, 300, 20, 300);
}
function horizontalLine (x1, y1, x2, y2) {
var x1 = 0;
var y1 = y2;
var line = new Line (x1, y1, x2, y2);
add(line);
}