Curiosity - Getting rid of variables

Hey Guys,

Just curious as to who else is approaching it ignoring the index variable entirely and making the call to Random.Range directly like so:

            case 1:
                Terminal.WriteLine("Can you crack the level 1 server?");
                password = level1passwords[Random.Range(0, level1passwords.Length)];
                break;

            case 2:
                Terminal.WriteLine("Can you crack the level 2 server?");
                password = level2passwords[Random.Range(0, level2passwords.Length)];
                break;

            case 3:
                Terminal.WriteLine("Can you crack the level 3 server?");
                password = level3passwords[Random.Range(0, level3passwords.Length)];
                break;

What was the reason behind not taking this route or introducing it? I guess I’ve been doing it this way for so long without an issue it begs the question as to if I could be doing something wrong or if its just a preference thing.

Obviously I’m just curious as to how fellow people taking this course feel.

Never mind!

Thats what I get for doing the social part before finishing the video >.> introduced

1 Like

hehe, glad you found your answer Robert :slight_smile:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms