100 Days of Code, Day 9:
21 June 2017
Today’s Progress:
Wrote a few for
loops today and executed them all quite well. Instead of using var
though I used let
so I could bind the counter to each iteration of the for
loop.
Now, after this, we went into functions, which I really want to nail down.
Of course we learned about functions and function declarations but we also went over arguments and calling functions, which I am pretty good with.
The best part of what I learned today though was the difference between console.log
and return
.
console.log
only writes to the console. It doesn’t return anything back to the function so therefore we can’t use the function call in another statement.
For instance:
This will write Hello there, Tiffany!
to the console. However when I try to call it again in a different statement, it writes to the console but returns undefined
as each function in the console will return undefined
if you don’t specify a return
statement.
Another instance:
This actually returns the value back to the function so that we actually get an output. So when I call it in another statement in the console, it will actually return a value instead of throwing undefined
.
Note about the console
You can tell a function will return a value by looking for the arrow in the output:
If it doesn’t have that small line coming out of the arrowhead, that means it is not returning a value. Colt is a pretty damn good instructor.
Thoughts:
It is starting to get harder now. I am digging it more now, if you can believe that.
Link to work:
For loop gists: