# How to compare number properties?

How can I make a block to compare 4 number properties and determine the largest one?

1 Like

Use blocks
multiple of them. EX if a>b then broadcast A else broadcast B. and so on.

Youâ€™ll need to use block code, in which you can use the â€śif/elseâ€ť conditional block to check if a number is greater than another number. If you have 4 numbers, you can create 16 unique 2-number combinations, so add 16 if/else blocks, each comparing 2 numbers. At the beginning of the script, set a variable called â€śgreatest numberâ€ť to 0. Then, inside the â€śifâ€ť section of each â€śif/elseâ€ť block (make sure you do add an â€śelseâ€ť section), set a variable called â€śgreater of pairâ€ť to the first property (the greater one). In the â€śelseâ€ť section, set the variable to the second property. add another if/else block that checks if the â€śgreater of pairâ€ť variable is greater than the â€śgreatest numberâ€ť variable. If it is not, do nothing and continue the script. If it is, set the â€śgreatest numberâ€ť variable to the â€śgreater of pairâ€ť variable. Make sure this is run after each of the 16 if/else blocks.

And youâ€™re done! At the end of the script, the â€śgreatest numberâ€ť variable will be the greatest of your four numbers.

Let me know if you need more details or have any questions or concerns!
Hope this helped!

5 Likes