Foundations badge

Fundamentals Part 2

Foundations Course

Introduction

There are a few extremely common types of data that you will encounter in JavaScript, and these lessons on fundamentals will give us a really strong foundation in all of them. Before we start digging deep, however, this article will give you a quick overview of the most common ones.

Lesson Overview

This section contains a general overview of topics that you will learn in this lesson.

  • Name the eight data types in JavaScript.
  • Understand the difference between single, double, and backtick quotes.
  • Embed a variable/expression in a string.
  • Understand what a method is.
  • Name the three logical operators.
  • Understand what the comparison operators are.
  • Understand what conditionals are.
  • Understand what nesting is.
  • Understand what truthy and falsy values are.

Strings

Depending on what kind of work you’re doing, you might end up working more with pieces of text rather than numbers. A string is simply a piece of text… and is a fundamental building block of the language.

  1. Read and code along with yet another MDN tutorial on the topic.
  2. Go through this lesson to learn a bit more about what you can do with strings… be sure to take a peek at the String Reference page near the bottom, and do the exercises at the end!
  3. Vocabulary time: a method is a bit of functionality that is built into the language or into specific data types. In the previous W3Schools exercise, you learned a few methods that can be used on strings, such as replace and slice. An exhaustive list of methods that can be used on strings can be found here.

Conditionals

Now it’s time for the fun stuff… So far we haven’t done much with our programming that you couldn’t do with simple math skills. Sure, we’ve told our computer how to do the math, so that makes it quicker, but the essence of programming is teaching the computer how to make decisions in order to do more involved things. Conditionals are how we do that.

  1. Step one in learning about conditionals is making sure you have a good grasp on comparisons.
  2. This tutorial is a great first glance at conditionals in JavaScript.
  3. This tutorial will teach you about logical operators. A little heads up regarding this reading’s tasks; there will be questions where you see alert() (with a number or string inside of the parenthesis), what’s happening here will be discussed later in the curriculum. Some of the answers may not make sense now but they are accurate and will come to be understood as you progress in the curriculum. Don’t worry too much about it now!
  4. This article reinforces the concept and provides several interesting examples of how you could use it building websites.
  5. This article covers the same basic concept (read through it as a review!) and - more importantly - offers the usual ‘tasks’ at the bottom of the page!
  6. This tutorial teaches you about the switch statement, which comes in handy when you have multiple conditions.

Assignment

To give you a good bit of practice, we have created some replit.com exercises for you to play with. We believe that it’s best to practice programming on your own computer, rather than in an online environment, but we’ll get to that soon enough.

Be sure to do the lessons in order presented here. Pressing “run” at the top will run the code. Read all directions, watch the terminal, and read all the errors. Don’t forget to use ‘console.log’ extensively.

To get started, create a free replit account and click “Fork” or “Remix” in order to have access to the exercises. Note: Feel free to browse the files on the left column in order to gain familiarity with it.

  • Exercise 1
    • In this exercise, you will be working out of the file called troubleshooting.js
  • Exercise 2
    • You will be working out of script.js, and you will use the console in the ‘webview’ pane to check your work. To access the console, click the wrench icon, which is located on the right side of the address bar within the ‘webview’ pane.
  • Exercise 3
    • You will be working out of math.js
  • Exercise 4
    • You will be working out of follow.js

Additional Resources

This section contains helpful links to other content. It isn’t required, so consider it supplemental.

  • Regular expressions, commonly known as regex, are a tool that matches or locates patterns in strings for string validation. Although it shouldn’t be your immediate solution this early on, you can still use this resource to understand how websites know that myemail@com isn’t a valid email address. On top of that, other solutions to filter out strings exist, and regex is considered a slow operation.

  • The Net Ninja’s Regular Expressions Tutorial.
  • When to avoid regular expressions.

Knowledge Check

This section contains questions for you to check your understanding of this lesson on your own. If you’re having trouble answering a question, click it and review the material it links to.

Are you interested in accelerating your web development learning experience?

Get started
Thinkful Logo

Thinkful

  • 5-6 months

    5-6 months

  • Job Guarantee

    Job Guarantee

  • 1-on-1 Mentorship

    1-on-1 Mentorship