Scratch tasks NEW?

Hello everyone

I'm not sure if I understood and solved this problem correctly. How would you solve it? Everything can be solved on scratch 😉

That's how I did it…

Regards and thanks in advance!! 🙂

(No Ratings Yet)
Loading...

Similar Posts

Subscribe
Notify of
2 Answers
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
ReimundAcker
2 years ago

You seem to have understood the task correctly, but you haven't solved it quite correctly yet.

The list glass consists of 4 elements, e.g.

At the beginning, the variable currentElement is set to 0:

You have to note that there is no element 0 in the list glass , because the numbering of the elements starts with 1!

So if you now do the following:

Then, elements 0, 1, 2, and 3 (that's 4 repetitions) are output in sequence. As mentioned, element 0 doesn't exist, but it is counted in the repetitions. However, element 4 is not output, as that would be the 5th repetition of the loop.

In other words, in the loop you must first increment the variable currentElement by 1 and then print the element corresponding to that number.

Furthermore, you should specify the number of loop iterations not with the fixed number 4, but with the variable length of glass . This has the advantage that this point doesn't have to be changed every time the number of elements in the list glass changes. It also makes the program easier to understand; because why "4" has to be used is less immediately obvious to a reader (or to yourself after a while) than if it were "length of glass" instead. [This applies generally to software development: Avoid constant values ​​(numbers, characters, etc.) in the program wherever possible, but instead use commented variables with descriptive names.]

Finally, it is good practice to generally close blocks, for example, here with "stop everything".

The finished Scratch program should look like this:

verreisterNutzer
2 years ago
Reply to  ReimundAcker

Thanks, I did that too.