I know I say it every day, but today is going to be a short day… and it actually is. I have an interview for a web developer spot next week and I need to get some practice in to try to get rid of this impostor syndrome a little bit. Since you, my fictitious readers, are still fictitious, I know you won’t mind. 🙂 I did get our bug fixed in some compacity, though. So, here’s what I did.
Bug Fix – It’s the User’s problem
I was going through my options and I got a little lost in the rabbit whole this morning. Yes, we can loop through the array and check if a exists. Let me tell you, there are a ton of resources and methods out there for how to do this. If the number does not exist… Great! Push the new object into the array. If the number does exist… Great! Create a new one and push the object into the array.
BUT!! What if that second number exists, too? We’d have to run back through the loop. The problem I couldn’t get around is we’re now past that loop. If we created another loop and another after that, we would still run the risk of being in this same position. So, with what i came up is to merely let the user handle it.
But the unique id box is UNEDITABLE!?!?!
I know… And it doesn’t have to be. What I did was installed a little loop right after the id creation. This loop goes through and checks to see if this id matches an existing id. If it does not, it finishes our function, alerts the user of their new id, pushes the object into the array, and send the user on their way. If the id matches another, then it alerts the user of this error and tells them to, “please try again”. Include a return after this alert to exit you out of the whole process. This way, the input fields don’t get cleared and the user can simply re-click the submit button. Here’s my code and the result.
Thank you much!


