Stuck in Intro to JS
Intro to JS: Drawing and Animation, Challenge: Lined paper
I am stuck on this challenge. Is there a way to find the answers, so I can progress to the next level?
i have a minor problem with the lined paper challenge. i did everything correct, but it says i still have a problem in my code and i don't! can anyone help?
Currently, there is no way to find the solution. For the challenge you're stuck on, you should review For Loops.
We have to see the code to find out.
hi i am also stuck there heres my code
for (var i = 0 ; i < 20 ; i += 1) {
var lineY = 20 + (i * 20);
line(0, lineY, 400, lineY);
}
for (var j = 0 ; j < 20 ; j ++) {
var lineX = 20 + (j * 20);
line(20,0, 20, 400);
}
Even I'm stuck with this lined paper challenge. I did make a grid but I can't figure out why Khan Academy didn't let me go onto the next video. But I do have a solution for you guys who are stuck with this challenge just like I am. Do a spin off of your challenge and people will give you a solution. If that doesn't work, try something else.
Can you please help me find a way?
Thanks, Manya
I have a problem solving it too. I also think that the Oh Noes error buddie is giving me an error that I think can never be true.
I got pass step one, but I can't do step two.
In Step 2 of the Lined Paper Challenge, we are asked to
. . . add a for loop that draws 20 evenly spaced vertical lines (lines that go from top to bottom) to turn the lined paper into grid paper.
And we are told
The first vertical line should have an x coordinate of 20, and the last vertical line should have an x coordinate of 400.
We are given the HINT code
for (var j = 0; j < 20; j++) {
var _____ = 20 + (j * 20);
line( ___, ___, ___, ___);
}
Take a look at how you changed the y arguments to create the horizontal lines. You will need to change the x arguments in a similar way to create vertical lines.
I know how to do the first step, but don't know how to do the second step. This is my code.
background(255, 255, 247);
stroke(173, 222, 237);
for (var i = 0; i < 20; i++) {
var lineY = 20 + (i * 20);
line(0, lineY, 400, lineY);
}
for (var j = 0; j < 20; j++) {
var lineX = 20 + (j * 20);
line(20, lineX, 400, lineX);
You are so close.
Remember that the syntax (or rules) of the line() function is
line(x1, y1, x2, y2)
In the first for loop, you used lineY to define the y-coordinates of the endpoints of the lines. Changing the y-coordinates makes horizontal lines.
Can you think of what to change to make vertical lines?
Please sign in to leave a comment.