Tech Junkie Blog

Latest Posts

Monday, July 16, 2018

In JavaScript when you define a function you get a built-in Arguments object, this object is an array-like object that puts the arguments/parameters of the your function in an object which can be accessed via indexes much like an array.

This can be useful if you have a function that takes multiple parameters, but you don't know how parameters there will be.  Let's modify our addNumbers function so that it can add more than two numbers using the Arguments object.

    <script>
        function addNumbers() {
            var sum = 0;

            for (var i = 0; i < arguments.length; i++)
                sum += arguments[i];

            return sum;
        }

        console.log("The sum of the numbers are " + addNumbers(1, 2, 3, 4, 5, 6, 7, 8, 9, 10));
    </script>







If you remember our previous addNumbers function it only takes two numbers and and add them.

With no parameters specified we can specify as many parameters as we want and add the numbers based on the number of parameters to get the total.  The draw back with this approach is that we don't have any named parameters, which means that we can only to the parameters via the arguments object like this argument[i].  However, we don't have to know the exact number of parameters ahead of time for our function.  So there is a trade-off.

Tuesday, July 10, 2018

In previous blog we've installed the CentOS operating system on VirtualBox however, when we reboot, it takes us to a text prompt.  In this blog we will be installing a graphical desktop environment to our operating system using "yum".  Follow the steps below to get the Gnome desktop in your CentOS.

1.  Make sure you have internet connection
2.  Click "Start" on your "CentOS" VM










Monday, July 9, 2018

A JavaScript function is a piece of code that is defined once and can be reused through your program.  A function can have arguments or parameters that you can pass into it and returns a value.  If an explicit return value is not specified the return value is "undefined".  During invocation of the function, the function returns the value of "this" keyword, which represents the context of the function.

As you can see a function is a lot like a method.  If a function is defined as a property of an object it is in fact called a method of the object.  It is import to keep in mind that functions in JavaScript are objects and they have the benefits of any objects, meaning they can be self contained, which provide them with a vast amount of flexibility.

The following code is a simple function that adds two numbers together


            
<script>
        function addNumbers(x, y) {
            return x + y;
        }

        console.log("The sum of 1 + 3 is " + addNumbers(1, 3));
</script>






The code above creates a function called addNumbers with two parameters and returns the sum of the two numbers

Tuesday, July 3, 2018

If you are a startup or an entrepreneur, learning Linux is essential. Most of the open source and latest innovations starts out with Linux such as Docker.  That's because Linux is for the most part free and has a great community of techies supporting it.  Even Microsoft loves Linux now, it even made a commitment by releasing SQL Server on Linux.  Although it could  be a fling, instead of a long term engagement.  Also if you noticed the Virtual Machines on the clouds are cheaper if you choose the Linux version.  In this series on Linux I will go over what you need to do to get yourself started on Linux.  The best way to learn about Linux is to install it on a Virtual Machine.  We could host it on the cloud, but then we need to pay for it.  There are some free-tiers but they are limited.  So we are going to use VirtualBox from Oracle to host our CentOS instance.

On the previous blog we went over how to create a new virtual machine for CentOS in VirtualBox.  In this blog we will go over how to install the CentOS ISO file on the new virtual machine that we've just created. Below are the step by step instructions of how to install CentOS on VirtualBox.

Step-By-Step Instructions:

1. Launch VirtualBox, right-click then select "Settings"


2.  Click on "Storage", you will see the disc icon is "Empty"

Monday, July 2, 2018

The Array.isArray() method is a useful method to determine object is of type array.  Let's demonstrate with some code.

    <script>
        var oilPrices = [70.15, 69.50, 71.23, 74.32, 69.50, 76.99];
        var iamObject = new Object();

        console.log(Array.isArray(oilPrices));
        console.log(Array.isArray(iamObject));
    </script>

The code above tests to see if the oilPrices array is of type array which it is, and then it tests to see iamObject is an array.  The console.log out put should return true, and the second console.log should return false.


Tuesday, June 26, 2018

If you want to know your way around Red Hat Enterprise Linux distribution, but the you don't have the financial ability to obtain a license.  CentOS is your best bet get to the the Red Hat Enterprise Linux official experience.  Because CentOS is a binary compatible version of Red Hat Enterprise Linux.  Meaning all the things that matters are the same, only the branding and logos are different.  CentOS is open sourced and can be downloaded for free.  Although it might be a couple of versions behind Red Hat Enterprise Linux.  But, you should be able to perform everything you can with CentOS that you can with Red Hat Enterprise.  Below is a step by step instruction on how to install CentOS in Oracle VirtualBox.

Step-By-Step Instructions:

1.  Type http://centos.org in your browser
2.  Click on the "Get CentOS Now" button