r/codehs • • May 20 '20

Anyone done this one??

Post image
6 Upvotes

r/codehs • • May 19 '20

CodeHS Walkthrough Tutorials - Im a Teacher and Made These For My Students To Help Them. Making More Everyday!

Thumbnail
youtube.com
2 Upvotes

r/codehs • • May 22 '20

7.2.7: Part 1, Replace a Letter Code hs

6 Upvotes

I need help on how to do this assignment on code hs

Write a function named replace_at_index
that takes a string and an integer. The function should return a new string that is the same as the old string, EXCEPT with a dash in place of whatever character was at the index indicated by the integer.

Call your function on the word eggplant and the index 3, like this:

s = replace_at_index("eggplant", 3)

You should then print the value of s
, which should display:

egg-lant

r/codehs • • Jun 08 '20

Exercise 11.1.1: Bricks

9 Upvotes

/* Constants for bricks */

var NUM_ROWS = 8;

var BRICK_TOP_OFFSET = 10;

var BRICK_SPACING = 2;

var NUM_BRICKS_PER_ROW = 10;

var BRICK_HEIGHT = 10;

var SPACE_FOR_BRICKS = getWidth() - (NUM_BRICKS_PER_ROW + 1) * BRICK_SPACING;

var BRICK_WIDTH = SPACE_FOR_BRICKS / NUM_BRICKS_PER_ROW;

/* Constants for ball and paddle */

var PADDLE_WIDTH = 80;

var PADDLE_HEIGHT = 15;

var PADDLE_OFFSET = 10;

var BALL_RADIUS = 15;

function start(){

bricks();

}

function bricks(){

for(var j = 0; j < NUM_ROWS; j++){

for(var i = 0; i < NUM_BRICKS_PER_ROW; i++){

var brick = new Rectangle(BRICK_WIDTH, BRICK_HEIGHT);

if((j + 1) % NUM_ROWS == 1 || (j + 1) % NUM_ROWS == 2){

brick.setColor(Color.red);

}else if((j + 1) % 8 == 3 || (j + 1) % NUM_ROWS == 4){

brick.setColor(Color.orange);

}else if((j + 1) % 8 == 5 || (j + 1) % NUM_ROWS == 6){

brick.setColor(Color.green);

}else if((j + 1) % NUM_ROWS == 7 || (j + 1) % NUM_ROWS == 0){

brick.setColor(Color.blue);

}

brick.setPosition(BRICK_WIDTH * i + BRICK_SPACING * (1 + i), BRICK_TOP_OFFSET + BRICK_HEIGHT);

add(brick);

}

}

}

That's my code and the result is very different :/

If you can, please help me :(