Finding the smallest factor of a number with JavaScript

Time to practice some code!

Create a function named smallestFactor that finds and displays the smallest factor of any number (num).

Then call the function by passing in the value of  100. It should display the number 2 as a result.

Whenever you’re ready to look at my examples please refer to


Is programming for me?

The first thing you should know about programming is this:

You need to be able to solve the problem yourself before you can write a program to solve it.

That makes you a problem solver. Are you a problem solver?
Are you willing to spend the extra time thinking about issues, potential problems, unexpected possibilities…

Read the whole article here:

A counter for a for loop in JavaScript is not essential

Did you know that a conditional expression controlling a FOR LOOP does not have to be a counter?
That’s right, all it needs to be is a Boolean expression of any kind.
Take the following loop as an example:

var finish = true;

for (var i = 0; finish === true; i++) {

    if (i >= 5) {
        finish = false;


// result: 0,1,2,3,4,5

Variable finish is originally true and as long as it is true the for loop will run just like a while loop would.
Then we can control the loop at any time by switching the value of finish to false as it was done by the conditional statement.


Dot Syntax

What is the meaning of the dot?
The dot signifies that we want to use something that’s inside something else.

console.log("log is inside of a console");"Tony de Araujo");
// search is a method which is inside of object myObject

Hope it helps!

New eBook Release: Practicing AngularJS in HTML

What is AngularJS?
AngulatJS is a new way of scripting the HTML DOM.
AngularJS is a framework. All you have to do is link your web page to Google’s content distribution network (CDN) and your HTML becomes supercharged with many utilities you can use to make it more dynamic.

Get your six lucky numbers with AngularJS

Hi dear reader,
If you have read my eBook Small Projects to Learn JavaScript – Drawing Six ‘Lucky’ Numbers
you’ll be pleased to know that I have converted the project into AngularJS.

AngularJS was not even mentioned in the book but I figured it was time to demonstrate a way of implementing AngularJS on the script and it is a cool implementation as you may see on the following link:

Happy coding!


JSPLAIN – A new Info Forum

In order  to expand my support for  those reading my publications at Amazon I have created a new site where each book exercise is being further explored.

The night is still young but I’m working at it countless hours a day.

Please visit:





Get every new post delivered to your Inbox.

Join 94 other followers