Quick Maths
Rage. So much rage the functions unit caused.
I did come close to calling it quits.
MAYBE YOU SHOULDN'T BE CODING.
PERHAPS PROGRAMMING IS TOO HARD FOR YOU.
Stick to writing.
I did come close to calling it quits.
Instead, I asked around and my boyfriend spent over half an hour explaining the function.
It was one little thing, I mixed up mathematical syntax with the JavaScript syntax.
This being the functions unit, I assumed coding would also follow the order of operations in math, which includes parentheses.
const getTax = (itemCount) => {
return getSubTotal(itemCount) * 0.06
}
For HOURS, I was trying to wrap my brain as to why in the getTax function getSubTotal was multiplying itemCount again. But no. No, no, no, no... that was the parameter. A parameter is a variable that will be given a value when called (the value is called an argument).
An essential piece of information that was left out of the curriculum is that mathematical calculations only occur with these four signs: +, -, /, and *.
Immediately, I thought:
It's quick maths, easy!
Also, it was the vernacular. "Make sure to pass it an argument," and my boyfriend said something about "passing it through." What quantum saying is that? Note to self: Become fluent in codespeak.
Also, it was the vernacular. "Make sure to pass it an argument," and my boyfriend said something about "passing it through." What quantum saying is that? Note to self: Become fluent in codespeak.
I realized that learning coding from one free resource was limiting. Instead of wasting more time stuck, I studied on w3schools. Read about global and local scope, coincidentally, it mentioned function arguments work as local variables inside functions. The following lesson was JavaScript Function Syntax which explained the composition of a function as a whole.
Codecademy is fantastic in laying down the groundwork for understanding the basics of a language. It was when I further looked on YouTube for tutorials, I discovered there were different styles of writing code in the same language. That was a big revelation because in my mind, programming was rigid and uniform. Why you do that? How could you write differently?!
This inspired me to seek more sources on the same topic. Just like reading the news, you want to be well-rounded and fully informed on a matter.
Since I have a membership with Toronto Public Library, I can learn on Lynda for free as well. That will probably be later, overwhelming myself with materials would not be wise.
This inspired me to seek more sources on the same topic. Just like reading the news, you want to be well-rounded and fully informed on a matter.
Since I have a membership with Toronto Public Library, I can learn on Lynda for free as well. That will probably be later, overwhelming myself with materials would not be wise.
Michael, my boyfriend, compared JavaScript's function syntax to f(x) to which the function depends on the value of x. On Quora, there were some really good, explain-like-I'm-five type answers about f(x) I copied in my notebook.
Comments
Post a Comment