
Sign up to save your podcasts
Or


Something that's really useful to know about is the handful of objects that come built into the JavaScript language.
These objects are tools that you can use to enable a wide range of useful functionalities in your applications.
From manipulating the user's URL location to changing elements on the screen, these objects will make you say “Hey! That's awesome!”
Here's a brief outline…
So there you have it, a list of helpful objects that you can tap into to add some extra useful stuff into your programs.
Now how about I give you some of the most common uses for each of these objects? I think that would be super helpful for you.
As mentioned, the document object is used to interact with elements in your HTML pages. The most common use (that I've seen) for the document object is to retrieve elements from the page and tinker with them.
Let's take a look at a basic HTML page and then modify its contents when you push a button.
Go ahead and try copy/pasting the code above into your own HTML file and open it in a browser. You'll see something interesting happen when you click on the “spice it up” button.
The part to note here is that we were able to modify the look & feel of the text by using the document.getElementById() object and function to assign that paragraph element to a variable called paragraphElement. Then we took the paragraphElement and changed its style a bit. Powerful stuff!
The location object is typically used to just forward a user onto a different URL. Let's create a simple webpage that forwards you to Google.com when you click on a button.
Go ahead and copy/paste this code into your own HTML file.
You'll notice that there's a button on the screen that says “Go to Google!”. Now when you click on it, it'll use the location object (located in via window.location) to send you off to Google.
The history object is really easy to comprehend. I don't think I'll need to give you a full example like I did above. I have confidence that you'll figure out how to make use of its functions.
As a guide, I'll show you how to invoke its functions:
The screen object is used to get the width and height of the screen of your user's device. This is most useful when you're trying to figure out how to display content on their screen.
With the advent of mobile devices, it's becoming more and more “polite” to give your users a nice viewing experience when they visit your website on a mobile device. Using the screen object will tell you exactly how big (or small) their device's screen really is.
Go ahead an click here to see how big your screen is.
Finally we come to the navigator object, which is used to determine intimate details about the browser that you're using.
This can be used to change the way a webpage looks or acts depending on the type of browser that's being used.
I know that one practical use of the navigator object that I used a while back was when I did some HTML5 programming (back when it wasn't as well supported as it is now). I wrote code that essentially only worked in a Chrome browser, so I would use the navigator to determine the type of browser my users were using, and display a warning message if it wasn't a Chrome (webkit) browser.
Here's some code that will break down the browser's details:
Try that code out for yourself and see what details may surprise you about the type of browser that YOU are using!
JavaScript provide a great library of built-in objects that can be used to your programming advantage.
You never know when you might come to a situation where you'll need to determine the type of browser someone is using, or when you might need to dynamically modify an element on the page.
So be sure to make yourself familiar with these objects and their many uses, it'll make you a far better JavaScript programmer.
And hey, speaking of being a better JavaScript programmer, be sure to type your email into the box below, you'll get a special freebie that will be sure to enhance your programming skills.
The post EP38 – JavaScript’s Built in Objects appeared first on Coders Campus.
One thing that threw me off when I started learning JavaScript (with a background in Java) was the fact that JavaScript has both undefined and null as possible values for a variable.
In Java, all we have is just null which means that the variable has no value.
So when I saw this additional value of undefined in JavaScript, I was confused… what did it mean?
When a variable has the value of undefined it means two things:
An example of this in JavaScript would be as follows:
So as you can see, I've declared a variable, but I haven't assigned a value.
Now if I were to inspect that person variable to see what value it contained, you'd see that it says “undefined”.
Here's what the output of this code would be:
Now it's also interesting to note that when we inspect the type that is assigned to our person variable, we'll get the type undefined. This makes sense if you remember reading this article on the different data types in JavaScript.
Okay, fair enough then right?
undefined means that there's nothing assigned to our variable… so then, what the heck does null mean?
In JavaScript null means that you've intentionally assigned a value to your variable, and therefore you're intentionally assigning the value of nothing to your variable.
You can think null like a place-holder, meaning that the variable has nothing inside of it, but you intend on assigning it a value later.
The interesting thing to note about assigning null to a variable is what type JavaScript gives to a variable that has been assigned the value of null. Let's take a look:
Here's the result:
What!?
The type of our person variable is object?
Believe it or not, this is a bug in JavaScript that they've just sort of “leaned into” and stuck with over the years. It's part of the way the JavaScript engine works and if they changed it now, it would likely cause some side-effects to a lot of code out there on the interwebs.
The common justification for this bug is that when you're using the value of null for a variable, it's because you're using it as a place-holder for an object that will be assigned to this variable later.
Not the greatest justification, but that's just how the cookie crumbles in this case.
The value of undefined is assigned to any variable that has not yet been assigned a value.
The value of null can be assigned by YOU if you like, and it represents a lack of a value (aka. nothing!)
Clear as mud?
Good!
No go and put your email address into the box below so I can send you a free goodie that you'll love. You've already read down to the bottom of this article, so I know you'll love the stuff I'll send to you.
Boo yah!
The post EP37 – Null vs Undefined in JavaScript appeared first on Coders Campus.
As we all know, JavaScript is an object oriented programming language, but we haven't yet gone into detail about how objects work in JavaScript.
Today, we're going to change that!
You see, Objects are by far the most powerful data type that exists in JavaScript and I'm about to show you why.
As you've seen briefly in other articles on this site, you've seen how to declare a variable that will be backed by the Object data type, kind of like this:
You can see that we use the open/close curly brackets to declare a variable in JavaScript that will be backed by the Object data type. I say that it will be “backed by the object data type” because you can't explicitly declare a variable as an object in JavaScript due to its dynamic typing.
In any case, this is a pretty mundane example of how to create an Object in JavaScript, so let's get more complex shall we?
The real magic with Objects in JavaScript is that you can assign properties to objects.
These are basically just name/value pairs (just like a Map in Java).
Let's go ahead and create a Person object in JavaScript:
Now what I've done here is I have created an object called Person with four properties:
I have created this person object using something called JSON, which stands for JavaScript Object Notation. So everything you see from the opening curly bracket to the closing curly bracket is JSON.
Note: my JSON isn't entirely valid, as the names of the properties should be strings, and I didn't use double quotes, but that's just because JavaScript doesn't complain and knows how to handle the code. So really my only excuse is that I'm lazy and don't want to type out a bunch of double quotes. For the sake of completion, here's what the declaration would look like with completely valid JSON:
You'll see here that each of the names of the properties are now wrapped in double quotes.
If ever you want to validate your JSON strings, then I'd recommend a site like JSONLint. It allows you to copy/paste your JSON string into an input box and hit a “validate” button to check your code. It will then show you errors if your JSON isn't properly formed.
Believe it or not, JavaScript also allows you to create objects without using the full JSON syntax. You'll still need to declare a variable with the open/close curly brackets, but then you can start populating the Object's properties with the dot property syntax.
Here's an example of how to populate an object's properties with the dot property syntax:
And now we have created an Object without using a whole bunch of JSON text!
Note: there are subtle differences between these two objects, but we won't dive into those crazy details until we talk more about an Object's prototype in a later lesson.
There's a great article on mozilla.org that sums up what Objects are in an elegant way:
JavaScript is designed on a simple object-based paradigm. An object is a collection of properties, and a property is an association between a name and a value. A property's value can be a function, in which case the property is known as a method. In addition to objects that are predefined in the browser, you can define your own objects.
So what I want to talk about now is creating property methods.
Remember that an Object can have properties, and those properties are comprised of a name and a value. For example a property name could be "gender" and a value could then be "Female". Pretty simple right?
But with the addition property methods, we can have a the value of a property be a function!
Let's add a function to our person object. As always there are two ways to do this, you can either use JSON or the dot property syntax. First let's take a look at the JSON syntax:
Now let's take a look at the dot property syntax:
Note: With the JSON code, we needed to add the goToWork function in with the original definition of the object, so there seems to be a lot more code when using the JSON syntax… but this code will be reduced once we talk more about the subject of prototypes.
Okay, so now that we've added a function as a property to our person object, all we need to do to “invoke” the function is this:
Once we run the code above, we'll get an alert saying "Trevor is now going to work".
We've only hit on a few key points with respect to JavaScript Objects and there are more tutorials to come that will cover other aspects of programming with Objects in JavaScript.
But so long as you can remember that Objects have properties, and properties are made up of name / value pairs, then you'll be in a great spot to keep on learning how to use Objects in JavaScript.
OH! Hey by the way, don't forget to put your email address in the box below for some free goodies. Seriously, I'll send you something very relevant to what you're learning now directly to your inbox. Check out the details in the box below.
The post EP36 – Objects in JavaScript appeared first on Coders Campus.
We know that JavaScript is a dynamically typed language, but remember, this doesn't mean that JavaScript is void of types.
JavaScript absolutely has types that back its variables, we're just sort of “abstracted” out of that process by its magic and wizardry. Okay it's not magic, it's just code, but it can seem like magic at times right?
So the real question here is, how can we determine the type that is assigned to any given variable?
Thankfully, JavaScript makes it easy to determine the type that backs any of your variables.
It's called the typeof keyword.
Here's an example of how it's used:
Here's the result:
There you have it! The type of myVariable is string.
So to determine any variable's type in JavaScript, you just need to put the typeof keyword before a variable and it will return a string that describes the variable's type.
There's really not much to the typeof keyword as you can see. It's quite straight forward to use and it just “works” like you'd imagine it would. Phew!
What may help you out is to know the different types that can be assigned to any given variable, so if you're fuzzy on the list, just check out this article to help refresh your memory.
And hey, don't forget to sign up for our mailing list below. I'm always giving out awesome free stuff and get such great feedback from my students with respect to how much they love what I send out. So it's likely worth your time and I promise never ever ever ever to sell or give away your information to anyone, that kind of business is just too sleazy for me!
The post EP35 – JavaScript TypeOf Keyword appeared first on Coders Campus.
If you come from a Java programming background, you're probably used to using the console to display information to the user as well as using something like the Scanner to retrieve data via the console as well. But with JavaScript it's a lot more straight forward.
You see, JavaScript offers not only console logging, but also a simple means by which to display messages and get inputs from the users.
This is what we'll be diving into today. First off, let's start with the easy stuff: displaying messages!
Displaying messages is as simple as using the alert function.
Here's a simple example of how to display an alert message with JavaScript:
If you'd like, you can go ahead and click here to see what that alert message looks like.
And it's really as simple as that!
As a rule of thumb, I would avoid overusing the alert function though, as users will get annoyed by having to click on “OK” over and over again.
Getting data from users using JavaScript is also very easy.
There are two functions you can use:
The prompt function is used to get textual or numerical (or both) data from the user. It will just put up a dialogue box on screen with any message you'd like to display along with a text box allowing them to input anything they like.
Here's an example of a prompt:
Notice that we use a variable (called response) to store the input that the user types into the prompt.
If you'd like, you can go ahead and click here to see what that prompt looks like.
The confirm function is used in a very similar fashion as the alert function, but with one big difference. The confirm function will show an alert box with two options “OK” and “Cancel”.
Here's an example of a confirm popup:
Notice that we use a variable (called response) to store the choice the user makes (either “OK” or “Cancel”). When the user clicks “OK” the response variable will be true, if the user clicks “Cancel” the response variable will be false.
If you'd like, you can go ahead and click here to see what the confirm popup looks like.
Thankfully this kind of user interaction is not rocket science and is fairly easy to follow.
If you're wondering if there are other methods for retrieving data from users in JavaScript, the answer is “Sort of”.
You see, JavaScript isn't really meant to be the primary source of showing or collecting input from webpage users. HTML is best used for these tasks.
So a typical scenario is to use HTML input tags to gather input from users and then you JavaScript code to validate that the data is valid before sending it off to a web server!
But if you're in a bind and need a quick way to show or get data from your users, then look no further than JavaScript and the three functions we talked about today.
PS. Don't forget that I'm always giving away awesome free stuff when you join our email list. I also don't sell or give away your email addresses to ANYONE, I never have and a I never will! So be sure to check out what free goodies I'm giving away by filling out the form below :)
The post EP34 – JavaScript Alerts and Prompts – Getting and Showing Data from Users appeared first on Coders Campus.
Every programming language that you'll use will have some sort of tool that allows you to debug the code you write.
Without debugging, finding the errors in your code would be VERY time consuming.
The magic of using a debugging tool is that it allows you to run your code line-by-line at a pace that you're comfortable with. This means that the computer won't just FLY through every single line of code and leave you guessing what the heck just happened. Debugging tools will allow you to dissect and inspect every single aspect of your code as it's running.
This is massively useful, as it allows you to spot any potential errors/bugs in a much more human way.
JavaScript is a bit unique as it exists in the browser that you use. So the tools that enable debugging in JavaScript will be different depending on which browser you use.
As I've mentioned before, I would recommend you use either the Google Chrome browser or Mozilla's Firefox browser.
If you're using Google Chrome, then you've already got the debugging tool built right into your browser, just hit the F12 key (or CMD + OPT + I on a Mac) and you'll see it pop up.
In Google Chrome, it's called the developer tools window and it actually gives you more than just the ability to debug your JavaScript code. It also allows you to inspect pretty much any aspect of any webpage you visit. But to stay on topic, I'll only talk about debugging.
I've actually done something special for this tutorial and I've included a JavaScript file, which you will be able to use as a debugging example. Aren't I so thoughtful? This will make it easier to explain the steps involved in debugging.
So, to start debugging the JavaScript file I've included in this blog post, follow these steps:
As you step through the code line by line, you'll see that the console messages will appear right when you hit the “step over” icon. Plus you'll get to see exactly how the for loop iterates over your code.
Debugging is not only a handy tool, but it can also serve as an educational tool for learning how the code functions as it's being run.
Update: When this post was originally written, Firefox didn't have a built in code debugger and you had to download ‘firebug' in order to enable this debugging functionality. This is no longer the case, you should be able to follow the instructions above and still be able to debug with Firefox without installing any additional plugins.
For the sake of completion, I've left the details on how to install the ‘firebug' plugin, just in case you prefer to use it…
Firefox uses a plugin called “Firebug” that will need to be installed. It's very similar to Google Chrome's Developer Tools. To download Firebug, go to this link: https://addons.mozilla.org/en-us/firefox/addon/firebug/, or if that link happens to be dead then just Google “Firefox Firebug” and you'll be sure to find a working link to install the plugin.
Once you've installed the plugin, you can launch it in the same way that you launch the Google Dev Tools, by hitting F12 (or CMD + OPT + I on a Mac).
The beauty about the Developer Tools / Firebug plugin is that they both function in nearly identical ways.
To debug your code using the Firebug plugin in Firefox, just follow the same steps that we've outlined above in the “Debugging in Chrome” section!
The post EP32 – Debugging in JavaScript appeared first on Coders Campus.
Functions in any programming language are almost as important as having variables. So that should go without saying that functions are hugely important to understand and to use in the JavaScript language.
That's really all they were created for. To organize the functionality of our code, and to allow us to re-use that code over and over again by “invoking” or “calling” the function.
So let's start things off by asking the following question: “What do you mean by organizing the functionality of your code?”
The first thing I'll point out is, look at the word “functionality”, isn't it interesting that it contains the word “function”?
Oh snap!
By functionality, I mean the actions that our programs perform.
Let's say we're looking to create a number guessing game. The computer will pick a random number between 1 and 100, and we are tasked with guessing what number the computer has picked. We have 5 guesses, and each time we guess, the computer will tell us if we need to guess higher, or lower.
Okay, cool, so we have an idea of how this game should work, now how would we outline the “actions” that this program should perform? In other words, how do we outline the functions that will exist?
Well the way I would do it is I would think about all the steps that would need to happen in order to carry out this task in real life. It might look something like this:
When you write out all of the steps, you can quickly see where some of the steps are similar based on how they repeat.
For example, I can see that the computer always needs to check if I was right, or if I need to guess higher, or lower. This is essentially an action that's performed MANY times by the computer… so this would be a perfect candidate for a function.
The second thing that happens often, is that *I* would attempt to guess a number, so that could be a function as well.
And finally, there's that bit at the beginning that only happens once, which is where the computer needs to pick a random number. What I would do here is just realize that this is something that happens when we START a game… or perhaps more specifically, something we do when we want to start a NEW game. So if we want to be able to play MANY games in a row, this could become a function as well, as we would need to invoke this many times.
So, we've outlined three functions, all we need to do is give them names.
That's right, functions need names, it makes the code more “human readable”, which is a good thing ;)
Let's talk syntax.
If you've got a Java programming background, this syntax will look slightly different. There's a specific reason why it's different though, and that's because JavaScript has dynamic types, so there's no need to specify a type in the function.
Here's a general outline of a function's syntax in JavaScript:
In the example above you'll notice that I have three parameters being “passed into” the function. This is just an example, and you can feel free to pass in ZERO parameters, or more.
The process of “passing parameters” into a function is very common in modern day programming languages. What's happening here is that the function is saying “Hey, I need certain parameters to be given to me in order for me to do my job correctly.” If you don't give a function what it wants, meaning, if you don't pass it the right number of parameters (whether that's none, one, two, three, or more) then the JavaScript engine will complain.
In the case of my generic example above, we have no concept of what the parameters mean or what they do, as it's just a generic example.
Here's an example of a generic function that doesn't require any parameters:
Voila, another function that this time doesn't require any parameters.
Alright let's talk real world examples now…
Let's break down what one of the functions would look like in our game. Let's use the function that verifies if the user has correctly guessed the randomly selected number. Before we just into the code, we'll need to make an assumption that somewhere above the code we're about to see, there's a variable that's been declared that holds the number we wish to guess. Let's call this variable numberToGuess.
Okay great, let's see the function:
First thing to note here is that we've assigned a meaningful name to the function. I decided that I wanted to call this function isNumberHigherOrLower, to me this is a pretty good name because it more or less defines what the code inside the function will be doing. If I wanted to be even more verbose, I could have named it isGuessedNumberHigherOrLowerOrCorrect, but there comes a point where super long function names just get annoying.
I'll let you decide what your threshold is for function name length!
The second thing to note is that I'm using the return keyword.
Functions can do one of two things:
This gives functions an added layer of usefulness, because not only can they allow you to re-use code and organize your code, but they can also give you relevant data based on the specific execution of the function.
So in the example of our function, a different value is returned based on what you pass in.
This means different INPUTS lead to different OUTPUTS.
Let's assume the number to guess is 50, based on this assumption, take a look at what our function would return based on the inputs we give it:
You see?
We get three different outputs from the function based on what number we input into the function.
So based on the outputs, we can have our game behave in different ways.
By the way, I also just showed you how to invoke/call a function. To tell your application that you want to “use” a function's code, you just type in the function's name followed by an open and close parenthesis… you should also pass in any values that it needs. In the case of our isNumberHigherOrLower function, it only wants one parameter, which we named usersGuessedNumber.
It can be a bit confusing if you've never seen a function in action before, but I assure you, you'll become very comfortable with them after you've created a handful of JavaScript programs for yourself.
JavaScript functions are very similar to Java functions with one major difference.
JavaScript functions don't require you to put in the parameter variable's type in the function's definition, this is because JavaScript uses dynamic typing, so it wouldn't make sense to put in a type for the parameter, right?
Functions are extremely useful and without them, all programming languages would be rendered pretty much useless.
So you need to learn them and master them.
If you don't quite “get it” yet, you'll be seeing plenty more examples of JavaScript functions in action in the coming tutorials.
And as always, don't forget to put your email address into our handy dandy box below to receive a free googie delivered right to your inbox. I'm pretty sure you're gonna want to check it out… I'm kind of a big deal ;)
The post EP31 – Functions in JavaScript appeared first on Coders Campus.
Everyone will, at some time or another, need to apply for positions and pass an interview or more to land the perfect job. Whether you are fresh out of school, or after years in the trenches, this applies to almost all of us. Often the competition can be fierce, you can simply drown in the torrent of applications some positions get.
What I’m going to try to summarise here, is how to improve one's chances of getting that first interview. Now, I’m not an expert in the area, but I have some personal experience actually getting the interviews. I am also basing this article on a couple of interviews my associate, Trevor Page, did for his podcast.
These interviews complement each other well, as they are from both the business' and an applicant’s point of view. Many of the tips will apply to many professions, but it's written for all the coders out there.
I would have to say that the number one, biggest chance of getting an interview, and hopefully the job, is your network. People you know have more information to go on considering you, than they do with the rest of the pile. This will usually move you to the top portion of the list. Having already established good chemistry will be of immense help.
This means that getting to know a lot of people in the right circles can be one of the best things to do, but it takes time. This means you ought to start as soon as possible. You also need to remember to be genuine and honest, to be yourself and to actually try to connect with people. If you do not, you will be just another face in the crowd, a possibly familiar name, but not someone to bump up a list.
Good places to do this sort of networking, outside school and current workplace, are meetups, hackathons, conferences and other similar events. These are events where like-minded meet and exchange thoughts and ideas. These are also great places to both gain knowledge and skills, as well as showing what you can do. Get to know some piece of awesome tech, make a cool DIY project or create a little something people might be interested in, and give a presentation on it.
Also remember that your network is where your references and letters of recommendations will come from. No one will vouch for you, if they don’t know you.
Now, for the application itself, it’s always a good idea to write a custom cover letter tailored for each position and company. Sure, many things will be the same or similar between them. There will however be enough unique qualities, skills and frameworks between positions, that taking the time to craft a well written cover letter will help you to stand out.
This cover letter needs to explain clearly why you are the right candidate for the position, why the company needs you to bring something unique to the table, and of course what that is. The letter must express who you are as a person and as a worker, perhaps let a few minor flaws shine through, but in a way that emphasises your best qualities or skills.
You should also consider writing a little about your ambitions and goals, as this will give them a clearer image of how you will fit over time. It’s naturally best if these ambitions and goals align with the company’s goals. Also, the letter should not be long, one to two pages at most, laid out in a readable way with short paragraphs, a nice readable font no smaller than 12 to 14 points in size.
To align the letter to the company you will have to research the company. Visit their website, read their brochures, look them up on wikipedia, google them, read news articles and press releases. Most importantly, actually read the job posting carefully. This research will also give you information you can use to ask well formulated questions about the company, the position and the person doing the interview.
Do not be afraid to actually picking up the phone and calling the contact listed in the job posting, even if they also list an e-mail address. Talking to the contact will always increase your chances of being remembered. Talk about the position, dig deeper into what the job will actually be, what type of product you will be working on, give a good impression and share something about yourself.
If you do not match the actual text and wording in the posting perfectly, you can still apply, but need to work even harder on your letter and phone call. You need to shine a light on what you bring that weighs up for what you’re missing, be it a degree, a framework or some other detail.
If you find you are lacking most of what they are asking for, you need to stop for a moment and do another assessment of your fit for the position. The less of a match you are, the less likely you are to get the interview. This is true even if your cover letter or phone call were perfect.
Being a junior and applying to senior positions is a long shot, and most likely will tell the company that you are unrealistic and overestimate your skills. The job posting is a reflection of an actual need that the company has for a specific skill set, and if you do not have any of what they ask for, you might be wasting everyone’s time.
A better option then is to send in an open application, not tied to a specific posting. Perhaps try to set up a meeting with someone from the company in a position to consider you. There might be other positions in the pipeline you are better suited for, and letting them know about you, could perhaps sometimes convince them to hire you without them having to go through all the hoops.
Your resumé will also have to be crafted for the position you are applying for. There’s no need showing off your entire life, just show the relevant experience and skills. Include relevant schools, degrees, courses and certifications, as well as some choice links to articles, posts, projects, papers and other resources that show off your work.
If you don’t have them already, chasing certificates as a coder is probably a waste of time and money. The certificates for software engineering does not carry the same weight as for system operations, architecture and security. The latter fields is where one often sees a requirement for such and such TOGAF, Microsoft or Cisco certification. It’s rare that a job will hinge on you being certified on Java, C# or HTML.
Always work on building your resumé. It really takes a long time and it is especially important when you are not actively looking for a job. This is because that is when you have the best opportunities to do so, already working with relevant topics.
You’ll need to write articles, blog posts or tutorials. Try to be active on support sites like Stack Overflow and build projects to show off. Maybe you can contribute to open source projects or perhaps you'll find some other way to stand out.
A recent informal survey asking hundreds of developers across the world what they valued most in prospective hires shows that contributing to open source projects is more important than even a bachelors degree. Mind you that this is what the developers themselves answered, not HR or the managers normally doing the hiring, but it shows that finding time to do this might be the best way to up your ante.
If you are lacking actual work experience, you can try to break the Catch 22 you are facing. Needing a job to get the experience you need to get a job, is fixed by actually getting that experience. There are other ways to get this than through a typical job. In doing so, starting with a blank slate, you can focus your efforts towards high demand areas. And this is where your chances improve due to lack of competition.
Getting this experience can involve doing contract work, lowballing a few bid to just get the experience. Perhaps freelancing online through sites like Freelancer or Upwork can help you there. Another option is to get the foot in the door by taking alternative positions within a company. Just be honest about your expectations and goals in the long run.
Volunteer work will also count. There are plenty of organisations and companies that need help, but can’t offer much of a budget. Summer internships is also something to look for if you need to get the ball rolling.
Let's expand a bit on what I wrote about showing off a few choice links in the “Resumé” section. These links need to point to something juicy if you really want to stand out. Blog about actual technical issues and their solutions, post some tutorials or give some YouTube-lectures. These lectures can be on Computer Science topics like data structures, algorithms or how the file system works.
If you are targeting DevOps positions, you should try to show off articles and projects related to that. This can be articles about hyper scaling, automation, continuous integration and deployment or cloud infrastructure. Learn the profession and share your knowledge.
Try to make things that actually works, rather than just posting code. A working website, a mobile app or online service is more convincing than just a pile of code. The code is good for getting to know you as a coder, but the end result shows that it works.
Don’t forget the effect of posting on social media and building a strong profile there. Now I’m not talking about Facebook, Instagram or SnapChat, but sites like LinkedIn, Stack Overflow, GitHub and Medium.
Ok, that was a lot of information at once, but important nonetheless. I have presented you with a variety of aspects regarding the job application. This will hopefully help you figure out how to stand out from the rest of the crowd. With these tips you should be able to shape your profile into something a prospective employer wants to dig deeper into.
By being active online, building social profiles, posting code and helping people, you will draw positive attention. Being able to express yourself clearly in the cover letter, using rich and appropriate language, also speaks volumes. Employers depend upon workers being able to communicate ideas, needs and documentation in a precise and understandable way.
Use your resumé wisely. Show off your best stuff, the most relevant items, experiences and interests. Build it continuously as you work or study. It takes a lifetime to fill, so start early. Remember to be optimistic, even though you should be realistic as well. Going out on a limb is something quite different from taking a leap of faith.
I'll leave you with this quote:
The way you personally communicate is 90 per cent of how you will be evaluated by any future employer.
The post EP30 – Landing the interview, a coder’s guide to applying for jobs appeared first on Coders Campus.
The while loop in JavaScript is yet another type of control structure. For a review on what a control structure is, please see our last post on IF statements.
The main goal of the while loop is to continually re-run a specific chunk of code over and over again. This is very similar to the for loop with one important difference. Again, if you aren't familiar with the for loop, please review the topic here.
Let me take a minute to explain the difference between these two types of loops.
The difference between these two loops is how they decide to STOP looping.
You see, the for loop has a specific and predefined number of iterations that it will make. We know exactly how many times a for loop will iterate once the code is running and the JavaScript engine starts executing the for loop's code.
This is in stark contrast to the while loop. The while loop keeps looping while a specific condition is true. Once the condition evaluates to false then (and only then) will the while loop stop looping.
The reason why this is so different than the for loop is that we don't necessarily know when this condition will change from true to false, so we can't really guess how many iterations the while loop will make until it stops.
This is both a good thing and a bad thing.
Let me start by addressing the only real “con” to the while loop.
It can run forever!
If you're in a situation where your while loop keeps looping to infinity, then your program is stuck (or frozen) and you'll need to shut down your browser to terminate the running JavaScript program. Not a very good user experience.
Having said that, an unruly while loop doesn't typically keep on running forever, because as good programmers we always make sure that our while loop's condition will at some point evaluate to false, right?
Right!
So the one rule you need to remember (and follow) is to always make sure that your condition will eventually evaluate to false.
Alright, having said that. The “pros” to using the while loop are quite abundant. Having a loop that will continually run until such time that a condition evaluates to false is very useful.
An example of a while loop in action would be asking a user for input again and again until they provide a valid input.
The syntax for the while loop is very straight forward.
You'll need to be sure to use the while keyword as well as defining the condition with which the loop will run. Also, like the other control structures, the while loop defines a scope.
Here's what the generic code looks like:
Pretty simple right? The hardest part is to figure out what condition(s) you need to put in the while loop for it to function properly.
Remember that while the condition(s) is/are true, the loop will continue to run.
Cool, so now let's take a look at a real world example of the while loop.
Let's assume we want to prompt the user with a question. We want to ask them to enter a number between 1 and 10.
But what happens if they enter an incorrect value?
Well, we should ask them to enter the value again, and to be sure to abide by the restrictions (i.e. enter a number between 1 and 10).
This is where a for loop would fail miserably, because how are we supposed to know ahead of time how many times we should ask them for the input… right? We haven't a clue! So in comes the while loop to save the day.
Here's what that code could look like:
What's interesting to note about the code example above is that we have three separate conditions in the while loop.
These three conditions are theNumber < 1 || theNumber > 10 || isNaN(theNumber). What this is saying is as follows:
So, because we're using the OR operator between each statement, this means that if ANY of the conditions are true, then the overall while loop's condition will evaluate to true, and thus it will continue to loop.
Only in the case that ALL three conditions are false, will the overall while loop's condition evaluate to false, and thus exit the loop.
So now, go ahead and try the code out for yourself!
The while loop is actually the only real loop in modern day programming languages. The for loop is actually just a special kind of while loop.
This is the case because you can re-create a for loop using the while loop's syntax… watch and learn:
As you can see, this code will run exactly 10 times, no more, no less. This is exactly the same functionality as a for loop.
Neat right?
So you shouldn't be afraid to use the while loop, because without it, there would be tons of applications out there that just wouldn't work properly at all!
I hope you enjoyed this tutorial, and if you did, be sure to put in your email address in the box below to get a free goodie delivered right to your inbox.
The post EP29 – While Loop in JavaScript appeared first on Coders Campus.
Just like an IF statement, a FOR loop in JavaScript is another kind of control structure.
The for loop's main purpose is to force the JavaScript engine to re-run lines of code a specific number of times. This is in contrast to the IF statement, which is used to potentially SKIP certain lines of code.
The processes of re-running lines of code over a specific number of intervals is known as iterating.
So the programming “jargon” for the for loop is to say “I'm iterating through my FOR loop”, which just means that you're re-running the same lines of code over and over again.
Re-running the same lines of code over and over again may seem a bit strange to someone who is new to programming, but let me assure you, it's incredibly useful and opens up HUGE possibilities for the creation of useful programs.
Let's take a look at the syntax for the FOR loop in JavaScript… if you come from a Java programming background it will look very similar (with the exception of the introduction of the dynamic typing concept):
For those of you who haven't seen these for loops before, this likely looks like a bunch of random letters and symbols. But let me assure you, they all have their purposes.
Note: Java programmers, take notice that we didn't declare the variable i as an int, we just used the var keyword due to the dynamic typing.
Alright, let's take a look at a generic version of JavaScript's for loop:
There are three different statements inside of a for loop:
Let me break down the purpose of each of these three statements:
Alright, so you're familiar with what a FOR loop looks like, but you might be asking yourself when you'd want to use one.
Let me answer that question with an example.
Here's some code that I use to do something stupidly simple: output the numbers 1 through 15 to the console:
I know, I know, this is a silly program, but I'm using it to illustrate a point.
This is an example of what a loop (specifically a FOR loop) is needed.
How do I know? Because there is some series repetition going on here.
Whenever you see repetition in code like this, it's probably a good idea to consider using a loop.
So how could we use a for loop to create the same output as the program above? Let's find out:
Done and done!
Here's what's going on in the FOR loop:
First it will run the initialization statement (it only runs this code once), that's the code that declares the variable i and sets it equal to 1.
Now that the for loop has declared the variable that it will be using to "execute" the loop, it moves on to check and see if it should terminate the looping... I know, it's a bit silly that it should have to check IMMEDIATELY if it should stop looping before its had a chance to do even ONE iteration, but believe it or not, this is a good thing, as it's predictable.
So, since it checks to see if it should terminate, it will run the termination condition, which at this point would be "Is i less than or equal to 15", and since i was just initialized as 1, it's checking if 1 is less than or equal to 15. Last time I checked, this was true, so it will execute the code inside the scope of the FOR loop.
The code inside the scope of the FOR loop is console.log(i), and remember that the current value of i is 1, so it will output "1" to the console. Great!
Then, since there's only one line of code in the scope of the FOR loop, it will try to loop over the entire scope of the FOR loop again. But before it loops, it need to go through a process that it ALWAYS goes through, which is to run the code in the iteration statement, then run the code in the termination condition statement.
Keep in mind that it ALWAYS runs the code in the iteration statement, then it runs the code in the termination condition statement. Over and over and over and over until the termination condition evaluates to false.
So for our example, what happens?
Well it runs the iteration statement, which is just i++, which increments the value of i by 1. So i now equals 2!
Then it runs the termination condition statement... "Is 2 less than or equal to 15?", yes it is! So... iterate again!
It will then output the number 2 to the console. Then it hits the end of the scope, so it will need to iterate, and possibly terminate. And round and round it goes until eventually, i is incremented to 16. Then when it runs the termination condition and asks "Is 16 less than or equal to 15?" the answer is false, so it terminates the loop.
And the result is that it has now outputted the numbers 1 through 15 to the console... which is exactly the same result as our code where we didn't use the for loop... but with our for loop program, we wrote a LOT less code!
Imagine if our requirement was to output the numbers 1 through to 1 million onto the screen... that would be a TON of typing if we weren't using a for loop. But WITH a for loop, it's the same amount of code as when we wanted to show numbers 1 through 15.
Neat right?
Thank god for FOR loops :)
Programming languages need loops. Without them, we just wouldn't be able to create the programs that we have available today.
Loops are not only a time saver, but have also saved the fingers and wrists of hundreds of thousands of programmers, possibly thwarting a global epidemic of carpal tunnel syndrome. So be sure to send a thank you letter to the creator of loops! And hey, if you happen to know who it was that created loops in programming, let me know in the comments section below.
And as always, don't forget to enter your email address in the box below this post. I'm giving away a free goodie for everyone who signs up, and it's sure to turn you into an even smarter cookie than you already are... and hey, no need to send me any thank you letters, it's my pleasure!
The post EP28 – For Loops in JavaScript appeared first on Coders Campus.
From the publisher's feed