Eloquent JavaScript Progress Report:
Introduction:
Learning Outcomes:
1: Programming is set of instruction used to interact with computer. Or to tell a computer what to do.
2: JavaScript is one of the computer language that we use to interact with browser. It is built in in almost
every web browser.
3: A program is data in the computer’s memory at the same time it controls actions performed on this
memory.(Program is a directing force what tells a computer what to do with date i.e. Which is also a
program).
4: In order to make a computer do what we want we have to figure out a way to connect these parts
and make it work according to our own needs.
5: Author disagree with programming best practices. He says someone made these practices from their
own convenience. But programming is very divers and young, so we have to leave room for new ways.
6: Good programming come with practice not from the set of rules predefined by someone.
7: We should write program that is easy to understand. And at the same time we should go outside the
box to try new things because modern problems require modern solutions. Sticking to only predefined
best practices might not be able to solve new problems.
Why computer Language Matters?
1: In early ages programs were written in binary i.e. 0’s and 1’s which was a very tedious task for example assign
number 0 to memory location 0 in binary would look like this.
……………………………………………………………………………………..
which was a very confusing task. Not humane readable.
so a more readably approach would be like this
Set “total” to 0.
Set “count” to 1.
[loop]
Set “compare” to “count”.
Subtract 11 from “compare”.
If “compare” is zero, continue at [end].
Add “count” to “total”.
Add 1 to “count”.
Continue at [loop].
[end]
Output “total”.
1. A simple instructions of English language are:
Store the number 0 in memory location 0.
2. Store the number 1 in memory location 1.
3. Store the value of memory location 1 in memory location 2.
4. Subtract the number 11 from the value in memory location 2.
5. If the value in memory location 2 is the number 0, continue with
instruction 9.
6. Add the value of memory location 1 to memory location 0.
7. Add the number 1 to the value of memory location 1.
8. Continue with instruction 3.
9. Output the value of memory location 0.
And here are those instructions in programming language
that computer will understand.
let total = 0, count = 1;
while (count <= 10) {
total += count;
count += 1;
}
console.log(total);
Most Important part about learning programming is to read
old code patiently and understand it.
And write your own solutions don’t just assume that you
know the solution try for yourself with different
approaches.
Program to calculate Factorial.
function factorial(n) {
if (n == 0) {
return 1;
} else {
return factorial(n - 1) * n;
}
}
Dry Run: