Run Your Code Frequently - TheOdinProject/blog GitHub Wiki
unsolicited advice: I see people ALLLLLL the time come in here with code that has multiple syntax errors and loooots of little things that cause it to not work correctly. For the most part this should NOT happen. I think what's going on is that people are sitting down and trying to write a large amount of their code, trying to get it ALL right from the beginning without ever running or testing the individual pieces that make it up....
In contrast the way that I usually write code is by starting small, running my program constantly, using things like console.log to make sure each piece is running and working as I expect it to from the very beginning.
So when I write something like the RockPaperScissors game, i might start with the function that compares 2 guesses and declares the winner... BUTTTTT before I write all the logic that declares the winner I'll probably do something like this:
function playRound(guess1, guess1) {
console.log(guess1, guess2)
}
playRound('rock', 'paper')
Just to make sure everything is set up and running correctly.... if this isn't running because of some syntax error then I can fix it quick!.
From there i'll go and write the logic piece by piece, testing it at every step of the way so that as soon as I write something that doesn't work correctly I'll know what part of the code is broken (i.e. it's probably the part i just wrote)
For what it's worth.. I don't mind helping people that have lots of problems, so i'm not really complaining about it from that point of view. I just struggle to understand how someone can write 100 lines of code that has soooo many little broken things scattered throughout the code.
TL;DR => RUN YOUR CODE 😉