I had to stumble my way through them on my own. Most of their mistakes were due to misunderstandings in the fundamental concepts like variables, values, objects, properties, and mutation.įace your misconceptions with no judgement.Ī misunderstanding that could be fixed in ten minutes can cause problems for years. Over the years, I’ve talked to hundreds of developers.įrom checking their mistakes, I’ve learned that it’s not advanced topics that caused them most trouble. Only, when you try to repeat what you saw, you get stuck on completely different things. It’s fun to watch someone build something. It just keeps on going.Ī video walkthrough won’t help you practice. A book can’t verify whether you really understood the concept. Still, your code is buggy and you don’t know why. You could read a 200-page book about how JavaScript works. But how much time do you really save if you keep making the same mistakes?Ī dry book won’t test your understanding. When there’s a fundamental gap in your understanding, it’s tempting to look the other way. Or, rather, you feel like you have to keep up. Now you have to keep up with all the new libraries and their updates, all the newsletters and tutorials, not to speak of all the problems you already encounter every day. It was hard enough to learn programming from scratch. You need to see what happens as your program runs. But to gain confidence and find that bug, you need more than that. They read it according to the rules created by other humans decades ago. They don’t guess its meaning from variable names and familiar patterns. This is a difficult thing to admit to yourself! But it’s never too late to revisit.Ĭomputers don’t read code the way we do. You’ve learned to write code, but you haven’t learned how to read it. When you were learning programming, you focused on writing code. But lack of confidence often reveals a real knowledge gap. Why does it take you hours to fix a bug that others fix in a few minutes? I’m just trying different things hoping that one of them works. Soon, a voice in your head becomes impossible to ignore. Your confidence wanes with every attempt. Should you remove this line? Reorder those two other lines? Maybe it will somehow just work if you try it again? Or did they? You’ve had to learn so much in so little time… The articles you’ve read and the tutorials you’ve watched did not prepare you for this moment. You read the code again and again, but you can’t spot the mistake. It strikes you in the middle of that interview. It strikes you during a pair coding session. It strikes you just as you were about to go home. Oh, what a marvellous illusion you have created! It works… With a few confident keystrokes, you breathe life into the colorful dots on the screen. You patiently enchant the machine with a tapestry of digital spells. You can refer to the "addTwoNumbers" function at the top of this page for an example.On a good day, programming feels like magic. If your function takes more than one argument, simply separate them with a comma inside of the parentheses. Otherwise, your code won’t work and you’ll get an error message. In the example above, you have to provide a number inside of the parentheses in order for the function to work and to receive a proper output. However, if a function does have parameters, you’ll need to provide values inside the parentheses when using the function: EXAMPLE In the example above, the function "greetThePlanet" simply returns the phrase "Hello World!", and it doesn't require any parameters (arguments) in order to do so. There can be zero, one, or multiple arguments in a function. Note that a function doesn’t have to have parameters - they can simply be left blank in the parentheses: EXAMPLE Once a JS function is defined (declared), you can use it by referencing its name with parentheses ( ) right after. Then you have to write the function logic between curly brackets To define a function, you must use the function keyword, followed by a name, followed by parentheses ( ). JavaScript functions are reusable blocks of code that perform a specific task, taking some form of input and returning an output.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |