First Solo project - what I did differently

I completed the project as described, but I did things slightly differently. Neither change is major, but I felt they were a bit cleaner for my purposes.

The first thing I did was add a clear screen when changing to “Password” state, so that the first prompt for a password was from a fresh screen. I just thought it looked better.

The second thing I did was to have two class level variables that hold the passwords (level1Password1, level2Password1) and assigned those at the point where the video assigns them to the “password” variable. I do a lot of scripting and I’ve always felt that if you need to hardcode something in a script/program, it makes more sense to do it as close to the top as possible, so it is easy to find and change. Also, if that value is going to be used in more than one place in the code, you can change it from the one location, and it is changed everywhere.

Ideally, the second change I made would have been easier/cleaner if I was able to use arrays, but I didn’t want to skip ahead to things we haven’t learned yet in the course.

Looking forward to the rest of the course!


Funny, I didn’t realize the next step in the course is about arrays!

Sounds like a good solution, and that you also have some programming experience!

Thanks. Little bit. Do a lot of scripting at work.

Privacy & Terms