I’m currently making a block which will return the word which has the longest length from a list of words.
I’m currently at the point where the block will work in some instances for example if the first word is longer than 2nd and so on. But if the first word is shorther than the 2nd it will not go through the whole list and just stop at the first instance of the condition being met.
I have included a picture of my current block. I’m sure I’m just being stupid but all help is welcome and I’d like to thank you all in advance.
The biggest misunderstanding here is that you're trying to REPORT after each item of the list, but a reporter can report only once; the first time you try to run that REPORT will end the procedure.
Once you have that under control, your algorithm can work.
Thanks for the response and warm welcome . I did get it to work with a different solution to this. But tbh I’m not quite sure why my working solution even returns the correct result.
I’ll add another post with a picture of my working solution if you’re interested (which I’m sure you aren’t lol)
You say SET UPDATED LIST TO ITEM. ITEM isn't a list, so neither is UPDATED LIST.
By the way, instead of taking a screenshot of the Block Editor, you should right-click on the hat block, the topmost block in the Block Editor, and choose "Script pic." Then when you post that picture, we can drag it into a Snap! window and get your actual code to play with.
Try applying your block to the sentence "the longest word".
The only little thing is that if MAXLENGTH is supposed to be a number, and you want to initialize it, you should set it to 0 rather than to an empty string. It doesn't affect the result, because Snap! treats strings of digits as equivalent to numbers. But actually you don't have to initialize them at all, I think, since you get 0 as a default value for new variables.