Hackathon project Help please

Student stuck: words not showing up next to dog image.

[Link to the project or level:(App Lab - Code.org)

What I expect to happen: [when either button is clicked, a picture of a dog and breed names should show up but they names are not showing up. ]

What actually happens: [The picture shows but not the names.

What I’ve tried: [compared old code that partially worked. I’m stuck too!

Old code link: App Lab - Code.org]

I see a few small errors that are easy to make …

The first is in line 19. Breed is a full array. Think about what your conditional is trying to compare.

The 2nd error is in line 25. When you run it, you will see that you have a uistring error. In this case, you are trying to set the “text” to be an array when “text” should be a string. (btw, you can’t use [i] here as you aren’t in the middle of an [i] loop).

Can you find a way to convert the contents of the entire array to be a string?

Does this help?

Mike

Thank you sooo much! Will fix tomorrow

There are several things missing in the updateScreenWorker() and updateScreen() functions. In the updateScreenWorker, we need a string where all the dog names must be concatenated to add to the text area. We also need a separate index variable for the WorkerNames list. See the code below.

function UpdateScreenWorker() {
  var s = ""; //String to save all the Worker Dog names
  var j = 0;  //index for the WorkingNames list
  for (var i = 0; i < DogNames.length; i++) {
    if (Breed[i] == "Working") {
      appendItem(WorkerNames, DogNames[i]);
      s += WorkerNames[j] + "\n"; //Add the dog name to the list
      j++; //increment the index
    }
  }
  console.log(WorkerNames);
  setScreen("LLworkers");
  setProperty("LLWorkers", "text", s); //set the text to the string that contains all the dog names
}

Similar changes need to made to the UpdateScreen function.

Did you see my other question regarding “/n”?

Thank you so much, will do the changes!!

Hey this code was updated and it worked. Thanks!