Fahrenheit to Celsius – JavaScript and AngularJS

You probably know how to convert Fahrenheit to Celsius in JavaScript but how would you display it on a web page?

Google has come up with a modern solution: AngularJS

AngularJS is a way to make your HTML more dynamic and it is easy to implement.

Take a look at my sample here:

Have fun testing it!


Can we run JavaScript tests on the Windows command prompt?

Yes we can ( once we install Node.js on our machine).
Node.js was first published by Ryan Dahl in 2009 and could only run on Linux.In June 2011, Microsoft partnered with Joyent to help create a native Windows version of Node.js.
Node.js is a cross-platform runtime environment for server-side and networking applications. Once installed on Windows we can do lots of things with it, one of such benefits is to run JavaScript on the command prompt.

Installation only takes minutes. Please see my other article on how to go about it, from installation to testing JavaScript on the command line:

Happy first of September, everyone!

JavaScript’s Conditional Operator

The conditional operator is a one liner if/else statement. Another name for it is ternary operator because it uses three operands:

expression1 ? expression2 : expression3;

If expression1 evaluates to boolean true, expression2 gets executed. Else, expression3 gets executed instead.

If you’re like me, you probably prefer to use if, else if, else statements, but the ternary operator can be very handy at times. One of the things we can’t do with our regular branching techniques is to include alternative outputs on a one console.log statement, but with the ternary operator we can:

var x = 10;
var y = 9;
console.log(x < y ? "hello!" : "goodbye!");
// it outputs "goodbye!"
console.log(x > y ? "hello!" : "goodbye!");
// it outputs "hello!"

Cool thing!

Calculus Made Easy

Have ever wondered if we could learn and practice math the way we learn a programming language?
Wouldn’t it be nice if there was such method out there? There is!
Take a look at this eBook:

Programming languages trends

So you’re learning a new programming language. Do you want to know where it stands in popularity?
According to the TIOBE Index C is number one at the moment followed by Java but Java seems to be sinking fast.

PHP and Ruby seem be be declining whereas JavaScript is moving up steadily.

The top 10 are C, Java, Objective-C, C++, Visual Basic, C#, PHP, Python, JavaScript, Transact-SQL.

Here’s the link should you be interested on looking further into it:


Functions with names versus anonymous functions

Anonymous functions are not really as anonymous as they look at first sight.
Take for example the following function:

var x = function () {
  return 10;

Is this an anonymous function or is it a function named x?

The answer is both. Actually this is a variable named x that points to an anonymous function.

There is no difference between x = 5; or x = “tony”;, or x = function() {…

All these are variable assignments. As a matter of fact if we fire up our Chrome/Opera/Epic consoles ( CTRL SHIFT j) we can test it.

  1. Paste the above function into the console.
  2. Then type x;  to see what it prints out: It prints out the anonymous function explicitly.
  3. Now make this function a self-invoking function by adding a pair of parentheses to the end of it:
    var x = function () {
      return 10;
  4. Let’s check what x is assigned to by typing x;
    Now x is assigned to 10, not to the function itself but to the end result of function execution.So when we look at functions as their end result assigned to some variable suddenly they start to make more sense.

I go into more detail about self-invoking function on my latest eBook:
JavaScript innerHTML: A Project in Three Acts (Small Projects for Mastering JavaScript)


How to learn code

We all have a way of learning that may be different from someone else’s way of learning. But even when our methods work for us, there is room for improvement.

There are layers of understanding in any topic worth learning. These layers have barriers that propel us forward or push us back. They are like river currents and when we swim against them we always lose. Many times it is best to just let the current take us down the river until we figure out a way of saving ourselves. The first most important thing is not to panic. The second important thing is not to get lazy. Just keep your target in mind, which is to get yourself to shore. As you go down the river, choose your direction, left margin or right margin, and swim in an angle. Eventually you will get to safe grounds.

Learning is no different! Every topic worth learning will have a current pushing us back. The key is not to push against it. Just let it be. Read a paragraph, take a break. During the break ask yourself questions. What was the meaning of the paragraph you had just read? If you can’t explain it, then ask yourself why you can’t? Be specific, write these questions down on a piece of paper. Then go back and read the paragraph again. Perhaps on the second take you will answer some if not all those questions. If you still don’t get it, google those questions to read possible answers. Don’t take someone else’s answer for granted, make it your own, in your own terms. Then go back a read that paragraph again. Take another break and ask yourself more question about it. Then move forward and tomorrow return again with a broader point of view.

Learning is an art. You are the artist and you need to learn on your own terms. Keep this technique in mind and do your own thing, but do it well and with intent.