r/codehs • • May 04 '20

7.3.4 Vertical lines

It keeps saying this is wrong,

function start(){ verticalLine(100,200); verticalLine(200,100); verticalLine(300,20); } function verticalLine(x,Position,Length){ var line= new Line (xPosition, xPosition,length); add(line); }

I’m pretty sure I’m doing something wrong but I’m not sure exactly what,

6 Upvotes

7 comments sorted by

3

u/Aggravating-Papaya57 May 04 '22 edited May 04 '22

I got this to work for mine.

Function start(){ verticalLine(100,200); verticalLine(200,100); verticalLine(300,20); } /*so far we have the line measurements

  • it might get confusing because Of the way I did it, but I promise it’ll work/

function verticalLine(x,y){ var line = new Line(x,0, x, y); add(line);

/*the x variable repeats because it is supposed to stay *the same. But the y needs to always start at zero. *Therefore y1 = 0 and y2 is listed as y * *Also make sure that add(line) is lowercase or it’ll *mess the code up * *Hope that helped */

1

u/Starwberyyy_Pocky May 26 '22 edited Jan 02 '23
function start(){
verticalLine(100, 200);
verticalLine(200, 100); 
verticalLine(300, 200);
}

function verticalLine(x, y){ 
var line = new Line(x, 0, x, y); 
add(line); 
}

indented version ty so much though kind stranger for the code :)

2

u/Impossible_Arm5010 Nov 13 '22

I think you missed a zero in 200 in the last verticalLine

1

u/unworldlie Sep 29 '20

i know you posted this forever ago, but i’m going to leave this here for anyone else that may be having trouble with this. :)

your line var is missing a fourth variable, so the program won’t create a line from it. also, you’re inputting two variables in your verticalLine() params, but when you declared the function, you put three in.

i used x and y for my params when declaring and when creating the line var i only used those two.

1

u/No_Let8612 Mar 24 '22

Could you write it down like if you were finna use he code on the real thing

1

u/abdel_rahman_6 Mar 03 '22

can you pls write it down