Question about Unit 6 Lesson 6

csd-unit-6-lesson-6

#1

in lesson 6 puzzle 15 I have to admit that I am stumped. I have tried multiple methods but keep getting stuck trying to enter a variable in as an id. What solutions have others come up with. Could we get some hints for this puzzle going forward?


#2

I’m not sure I understand the question - when you say “enter a variable in as an id” do you mean using a variable in place of an element ID in a block like setText? If so, what kind of behavior are you seeing when you try to do it? FWIW, this puzzle has been removed from the next version of the Unit 6, expected to be released by the end of the month.


#3

Does anybody have any sample solutions to the final motorcycle puzzle? I am a see when it comes to CS and I am piloting this for my school. We(Students and myself) are stumped on this one.


#4

Is this the correct code for Lesson 6 Puzzle 16 (motorcycle with slider):

// Set the speed of the motorcycle
var speed = 10;

// Move the motorcycle up when the left button is clicked
onBoardEvent( buttonL, “press”, function(event) {
var y = getProperty(“motorcycle”, “y”);
setProperty(“motorcycle”, “y”, y - speed);
});

// Move the motorcycle down when right button is clicked
onBoardEvent( buttonR, “press”, function(event) {
var y = getProperty(“motorcycle”, “y”);
setProperty(“motorcycle”, “y”, y + speed);
});
onEvent(“slider”, “change”, function(event) {
speed = getProperty(“slider”, “value”);
});


#5

You need to create an event that sets the speed variable to the slider value when the slider is changed. See below:

// Set the speed of the motorcycle
onEvent(“setSpeed”, “change”, function(event) {
var speed = getProperty(“setSpeed”, “value”);

// Move the motorcycle up when the left button is clicked
onBoardEvent( buttonL, “press”, function(event) {
var y = getProperty(“motorcycle”, “y”);
setProperty(“motorcycle”, “y”, y - speed);
});

// Move the motorcycle down when right button is clicked
onBoardEvent(buttonR, “press”, function(event) {
var y = getProperty(“motorcycle”, “y”);
setProperty(“motorcycle”, “y”, y + speed);
});
});