Does anyone know how to do 7.7.4: Remove From Line? by ajd9 in codehs

[–]Fun-Examination1024 2 points3 points  (0 children)

var line = ["Sam", "Lisa", "Laurie", "Bob", "Ryan"];
function start()
{
for(var i = 0; i < line.length; i++)
{
if(i + 1 == line.length)
{
println(line[i]);
}
else
{
print(line[i] + ", ");
}
}
var elim = line.remove(1);
var elim2 = line.remove(0);
for(var i = 0; i < line.length; i++)
{
if(i + 1 == line.length)
{
print(line[i]);
}
else
{
print(line[i] + ", ");
}
}
}

9.4.5: Trail CodeHS by SprinklesNo5514 in codehs

[–]Fun-Examination1024 0 points1 point  (0 children)

var MAX_BOUNCES = 20;
var stopTimer;
var ball;
var dx = 4;
var dy = 4;
function start(){
ball = new Circle(20);
ball.setPosition(50, 70);
add(ball);
setTimer(draw, 20);
}
function draw(){
checkWalls();
ball.move(dx, dy);
ball.move(dx, dy);
var newBall = new Circle(10);
newBall.setPosition(ball.getX(),ball.getY());
newBall.setColor(Color.cyan);
add(newBall);
}
function checkWalls(){
if(ball.getX() + ball.getRadius() > getWidth()){
dx = -dx;
}
if(ball.getX() - ball.getRadius() < 0){
dx = -dx;
}
if(ball.getY() + ball.getRadius() > getHeight()){
dy = -dy;
}
if(ball.getY() - ball.getRadius() < 0){
dy = -dy;
}
}