Skip to content

LaunchCodeEducation/flexpath-revisit-looping-and-cond-branch-exercises

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

flexpath-revisit-looping-and-cond-branch-exercises

Exercise overview

Now that you have the basics of JavaScript and working with JavaScript in the web down, we wanted to revisit some fundamental concepts and give you a deeper understanding of how to use them effectively in your programs.

These exercises will take a closer look at looping and conditional branching in JavaScript.

Getting Started

  1. Using Visual Studio Code, open the folder flexpath-revisit-looping-and-cond-branch-exercises wherever you saved it on your device.
  2. Then open the flexpath-revisit-looping-and-cond-branch-exercises/exercises folder. Inside are a collection of folders for each exercise. Exercise instructions are provided to you in .txt files in these folders.
  3. To test your code, you will open up your terminal, and navigate to the specific exercise_[number] folder inside of the larger exercises/ folder where you are working in, using the change directory command cd.
  4. You will then run the command node [filename].js to run whichever file in the folder you are working with, replacing [filename] in the command with the file's actual name.

Exercise solutions are in the /solution folder

Note:

For the first few exercises in this repository, we have included example JS code you can use to test your solutions.

But, after the first few exercises we don't provide it anymore.

As a Software Developer, you will have to both solve a problem given to you and come up with code on your own to test that your solution to that problem actually works.

This is an important skill to build, and it is vital to being able to do this job.

Therefore, we want you to start getting comfortable writing JavaScript code to test that your solutions work as intended.

 

Summary of JavaScript Concepts Covered in These Exercises

  1. Looping Constructs:

    • Classic For Loop: Understanding initialization, condition, and iteration. Common pitfalls such as off-by-one errors.
    • For-Of Loop: Iterating over arrays and other iterable objects. Differences between let and const usage in loops.
    • For-In Loop: Iterating over object properties and understanding the nuances compared to for-of.
    • While and Do-While Loops: Usage and typical errors, like infinite loops and index mismanagement.
    • ForEach Loop: Using forEach on arrays and understanding how it handles sparse arrays differently from traditional loops.
  2. Advanced Iteration:

    • Handling Sparse Arrays: Differences between regular loops and forEach.
    • Using Functional Methods: Methods like filter, map, reduce, find, some, and every for array manipulation.
    • Performance Considerations: Best practices for optimizing loop performance and when to use break or early exit conditions.
  3. Branching Constructs:

    • If-Else Statements: Proper usage with and without braces and common errors to avoid.
    • Switch Statements: Understanding fall-through behavior, best practices, and grouping case statements.
    • Ternary Operator: Writing concise conditional logic.
    • Falsy and Truthy Values: How JavaScript handles falsy and truthy values and common pitfalls.
  4. Nullish Coalescing:

    • Nullish Coalescing Operator (??): Simplifying checks for null or undefined values and using default values efficiently.
  5. Practical Applications:

    • Scraping data from HTML elements using DOM methods.
    • Interacting with data structures like Maps, Sets, and HTMLCollections.
    • Error handling in loops and preventing infinite loops.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published