Hackathon Help in Unit 6 Lesson 13

I have a student who is having an issue with her code and I can’t figure out what is wrong. Can someone help? Here is the code:

//Varibles
var planets = [getColumn(“Planets of our Solar System”, “Planet”)];
var diameter = [getColumn(“Planets of our Solar System”, “Diameter”)];
var density = [getColumn(“Planets of our Solar System”,“Density”)];
var temp = [getColumn(“Planets of our Solar System”, “Mean temperature” )];
var gravity = [getColumn(“Planets of our Solar System”, “Gravity” )];
var image = [getColumn(“Planets of our Solar System”, “Picture”)];

var sun = [getColumn(“Planets of our Solar System”, “Distance from sun”)];
var day = [getColumn(“Planets of our Solar System”, “Length of day” )];
var moons = [getColumn(“Planets of our Solar System”, “Number of moons”)];
var mag = [getColumn(“Planets of our Solar System”, “Has global magnetic field” )];

var number = 1;

updatePlanetsScreen();

//HomePage
//Screen Buttons
//planet
onEvent(“PlanetInfoButton”,“click”,function( ) {
setScreen(“PlanetsScreen”);
updatePlanetsScreen();
});

//Plantets Screen
//text

//Update Planets Screen Function
function updatePlanetsScreen(){
setProperty(“TitleScreenImage”,“image”, image[1]);
}

Hi @christine.cox,

Can you please click “share” on the student’s project and place that link here so we can look at the code in there?

Also, what outcome is the student expecting to have? What outcome is she actually seeing? What steps have the two of you taken to solve it?

Given the wide variety of possible Hackathon projects, it’s helpful if we know what result we are looking for when debugging.

Thank you!
– Michael K.

Here is the link: App Lab - Code.org
I’ve been told before on here that my links don’t work because other users don’t have permission to see the student’s work, but hopefully this will work.
We are expecting the image to display as soon as “run” is clicked but the image is not showing up.

Hi @christine.cox ,

Unfortunately, I am not able to access the link you sent - you’re right that it does not allow permissions. Here is a project that I made based on your code - sorry, I don’t have any of the UI. I threw some items on the page to match the titles I saw in your code.

The issue with the student code is that they have wrapped the getColumn() call inside of an array : [getColumn()]
Because getColumn() actually returns an array, it is then creating an array inside an array:
image = [[ “image1_URL”, “image2_URL”, … “imagen_URL”]]

Wen you access the first element in the list, you’re actually accessing the first element in the outer list, which is the WHOLE inner list. And trying to turn that in to an image? The computer will get confused.

So, long story short, the quick fix is to remove the outside of each getColumn() call so the Array is stored as expected.

Good luck!
Madeline

1 Like