Doing Password with Arrays


So I tackled this challenge attempting to figure it out by doing it with Arrays of different strings. Considering I have programming experience, I just had to know what array methods were available to me in C# considering I’m mostly Javascript. Hopefully, this helps those in finding alternative solutions and bigger challenges to what’s been taught.

Thanks for sharing this, great solution.

Just a small naming convention tip, usually position refers to a vector, the int named position confused me for a second there, I suggest using another name like index.

I definitely appreciate the advice thanks. But allow me to play devil’s advocate a little. Is it truly a naming convention that position always refers to vectors when you see the word position (even though it isn’t a vector), or is it strictly a matter of preference? For me when I coded this, I generally do gravitate between “position and index” for naming the current “position” or the current “index” or the selected of the aforementioned for when I’m wanting that element’s position or index in the array. That’s a matter of personal preference for me. While I will agree with you that in this case it is a change I probably should make as it relates to vectors, because it isn’t technically, I could theoretically just keep it as “position” as a matter of personal preference. Of course I’m not building this code for other developers to work out of as well so the naming conventions are not of particular importance as generally if you work on a team one developer’s personal preference for variable naming is going to be different than other developer’s preference of naming variables. But since this is a solo project, I felt it to be preferably for my brain to have selected that variable name. However, again, I’m agreeable to changing the name. Just wanted to give a alternative side to the discussion.

1 Like

I totally agree, is about personal preference at the end, I was just trying to say that I found quite interesting that I got extremely confused with your code for a second due to naming conventions, which I did very poorly now that I re-read what I wrote.

But, even tho I agree with you, at the end it might result in confusion even for yourself in the long run since Unity uses the word position a lot and it always implies a position in the world and not an index. That’s probably why I got so confused, Unity’s MonoBehaviour forced me into that convention without me realizing.

Ahh so Unity has something specific for “position” that I did not yet know about. Appreciate you bringing that up.