freeCodeCamp.org - JavaScript Algorithms and Data Structures

While HTML and CSS control the content and styling of a page, JavaScript is used to make it interactive. In the JavaScript Algorithm and Data Structures Certification, you'll learn the fundamentals of JavaScript including variables, arrays, objects, loops, and functions. Once you have the fundamentals down, you'll apply that knowledge by creating algorithms to manipulate strings, factorialize numbers, and even calculate the orbit of the International Space Station. Along the way, you'll also learn two important programming styles or paradigms: Object Oriented Programming (OOP) and Functional Programming (FP).

Basic JavaScript JavaScript is a scripting language you can use to make web pages interactive. It is one of the core technologies of the web, along with HTML and CSS, and is supported by all modern browsers.

Prerequisites

  • JDK SE 18 ORACLE JDK SE or any newer version of JDK has to be installed on your system in order to run scripts from this tutorial.

  • VS Code for running scripts VS code.

Contents

In this course, you'll learn fundamental programming concepts in JavaScript. You'll start with basic data structures like numbers and strings. Then you'll learn to work with arrays, objects, functions, loops, if/else statements, and more.

Main scripts

Collapse courseBasic JavaScript

  1. Comment Your JavaScript Code
  2. Declare JavaScript Variables
  3. Storing Values with the Assignment Operator
  4. Assigning the Value of One Variable to Another
  5. Initializing Variables with the Assignment Operator
  6. Declare String Variables
  7. Understanding Uninitialized Variables
  8. Understanding Case Sensitivity in Variables
  9. Explore Differences Between the var and let Keywords
  10. Declare a Read-Only Variable with the const Keyword
  11. Add Two Numbers with JavaScript
  12. Subtract One Number from Another with JavaScript
  13. Multiply Two Numbers with JavaScript
  14. Divide One Number by Another with JavaScript
  15. Increment a Number with JavaScript
  16. Decrement a Number with JavaScript
  17. Create Decimal Numbers with JavaScript
  18. Multiply Two Decimals with JavaScript
  19. Divide One Decimal by Another with JavaScript
  20. Finding a Remainder in JavaScript
  21. Compound Assignment With Augmented Addition
  22. Compound Assignment With Augmented Subtraction
  23. Compound Assignment With Augmented Multiplication
  24. Compound Assignment With Augmented Division
  25. Escaping Literal Quotes in Strings
  26. Quoting Strings with Single Quotes
  27. Escape Sequences in Strings
  28. Concatenating Strings with Plus Operator
  29. Concatenating Strings with the Plus Equals Operator
  30. Constructing Strings with Variables
  31. Appending Variables to Strings
  32. Find the Length of a String
  33. Use Bracket Notation to Find the First Character in a String
  34. Understand String Immutability
  35. Use Bracket Notation to Find the Nth Character in a String
  36. Use Bracket Notation to Find the Last Character in a String
  37. Use Bracket Notation to Find the Nth-to-Last Character in a String
  38. Word Blanks
  39. Store Multiple Values in one Variable using JavaScript Arrays
  40. Nest one Array within Another Array
  41. Access Array Data with Indexes
  42. Modify Array Data With Indexes
  43. Access Multi-Dimensional Arrays With Indexes
  44. Manipulate Arrays With push()
  45. Manipulate Arrays With pop()
  46. Manipulate Arrays With shift()
  47. Manipulate Arrays With unshift()
  48. Shopping List
  49. Write Reusable JavaScript with Functions
  50. Passing Values to Functions with Arguments
  51. Return a Value from a Function with Return
  52. Global Scope and Functions
  53. Local Scope and Function
  54. Global vs. Local Scope in Functions
  55. Understanding Undefined Value returned from a Function
  56. Assignment with a Returned Value
  57. Stand in Line
  58. Understanding Boolean Values
  59. Use Conditional Logic with If Statements
  60. Comparison with the Equality Operator
  61. Comparison with the Strict Equality Operator
  62. Practice comparing different values
  63. Comparison with the Inequality Operator
  64. Comparison with the Strict Inequality Operator
  65. Comparison with the Greater Than Operator
  66. Comparison with the Greater Than Or Equal To Operator
  67. Comparison with the Less Than Operator
  68. Comparison with the Less Than Or Equal To Operator
  69. Comparisons with the Logical And Operator
  70. Comparisons with the Logical Or Operator
  71. Introducing Else Statements
  72. Introducing Else If Statements
  73. Logical Order in If Else Statements
  74. Chaining If Else Statements
  75. Golf Code
  76. Selecting from Many Options with Switch Statements
  77. Adding a Default Option in Switch Statements
  78. Multiple Identical Options in Switch Statements
  79. Replacing If Else Chains with Switch
  80. Returning Boolean Values from Functions
  81. Return Early Pattern for Functions
  82. Counting Cards
  83. Build JavaScript Objects
  84. Accessing Object Properties with Dot Notation
  85. Accessing Object Properties with Bracket Notation
  86. Accessing Object Properties with Variables
  87. Updating Object Properties
  88. Add New Properties to a JavaScript Object
  89. Delete Properties from a JavaScript Object
  90. Using Objects for Lookups
  91. Testing Objects for Properties
  92. Manipulating Complex Objects
  93. Accessing Nested Objects
  94. Accessing Nested Arrays
  95. Record Collection
  96. Iterate with JavaScript While Loops
  97. Iterate with JavaScript For Loops
  98. Iterate Odd Numbers With a For Loop
  99. Count Backwards With a For Loop
  100. Iterate Through an Array with a For Loop
  101. Nesting For Loops
  102. Iterate with JavaScript Do...While Loops
  103. Replace Loops using Recursion
  104. Profile Lookup
  105. Generate Random Fractions with JavaScript
  106. Generate Random Whole Numbers with JavaScript
  107. Generate Random Whole Numbers within a Range
  108. Use the parseInt Function
  109. Use the parseInt Function with a Radix
  110. Use the Conditional (Ternary) Operator
  111. Use Multiple Conditional (Ternary) Operators
  112. Use Recursion to Create a Countdown
  113. Use Recursion to Create a Range of Numbers

ES6

ECMAScript, or ES, is a standardized version of JavaScript. Because all major browsers follow this specification, the terms ECMAScript and JavaScript are interchangeable.Most of the JavaScript you've learned up to this point was in ES5 (ECMAScript 5), which was finalized in 2009. While you can still write programs in ES5, JavaScript is constantly evolving, and new features are released every year.ES6, released in 2015, added many powerful new features to the language. In this course, you'll learn these new features, including arrow functions, destructuring, classes, promises, and modules.

Collapse courseES6

  1. Compare Scopes of the var and let Keywords
  2. Mutate an Array Declared with const
  3. Prevent Object Mutation
  4. Use Arrow Functions to Write Concise Anonymous Functions
  5. Write Arrow Functions with Parameters
  6. Set Default Parameters for Your Functions
  7. Use the Rest Parameter with Function Parameters
  8. Use the Spread Operator to Evaluate Arrays In-Place
  9. Use Destructuring Assignment to Extract Values from Objects
  10. Use Destructuring Assignment to Assign Variables from Objects
  11. Use Destructuring Assignment to Assign Variables from Nested Objects
  12. Use Destructuring Assignment to Assign Variables from Arrays
  13. Use Destructuring Assignment with the Rest Parameter to Reassign Array Elements
  14. Use Destructuring Assignment to Pass an Object as a Function's Parameters
  15. Create Strings using Template Literals
  16. Write Concise Object Literal Declarations Using Object Property Shorthand
  17. Write Concise Declarative Functions with ES6
  18. Use class Syntax to Define a Constructor Function
  19. Use getters and setters to Control Access to an Object
  20. Create a Module Script
  21. Use export to Share a Code Block
  22. Reuse JavaScript Code Using import
  23. Use * to Import Everything from a File
  24. Create an Export Fallback with export default
  25. Import a Default Export
  26. Create a JavaScript Promise
  27. Complete a Promise with resolve and reject
  28. Handle a Fulfilled Promise with then
  29. Handle a Rejected Promise with catch

Regular Expressions

Regular expressions, often shortened to "regex" or "regexp", are patterns that help programmers match, search, and replace text. Regular expressions are very powerful, but can be hard to read because they use special characters to make more complex, flexible matches.In this course, you'll learn how to use special characters, capture groups, positive and negative lookaheads, and other techniques to match any text you want.

Collapse courseRegular Expressions

  1. Using the Test Method
  2. Match Literal Strings
  3. Match a Literal String with Different Possibilities
  4. Ignore Case While Matching
  5. Extract Matches
  6. Find More Than the First Match
  7. Match Anything with Wildcard Period
  8. Match Single Character with Multiple Possibilities
  9. Match Letters of the Alphabet
  10. Match Numbers and Letters of the Alphabet
  11. Match Single Characters Not Specified
  12. Match Characters that Occur One or More Times
  13. Match Characters that Occur Zero or More Times
  14. Find Characters with Lazy Matching
  15. Find One or More Criminals in a Hunt
  16. Match Beginning String Patterns
  17. Match Ending String Patterns
  18. Match All Letters and Numbers
  19. Match Everything But Letters and Numbers
  20. Match All Numbers
  21. Match All Non-Numbers
  22. Restrict Possible Usernames
  23. Match Whitespace
  24. Match Non-Whitespace Characters
  25. Specify Upper and Lower Number of Matches
  26. Specify Only the Lower Number of Matches
  27. Specify Exact Number of Matches
  28. Check for All or None
  29. Positive and Negative Lookahead
  30. Check For Mixed Grouping of Characters
  31. Reuse Patterns Using Capture Groups
  32. Use Capture Groups to Search and Replace
  33. Remove Whitespace from Start and End

Debugging

Debugging is the process of going through your code, finding any issues, and fixing them. Issues in code generally come in three forms: syntax errors that prevent your program from running, runtime errors where your code has unexpected behavior, or logical errors where your code doesn't do what you intended. In this course, you'll learn how to use the JavaScript console to debug programs and prevent common issues before they happen.

Collapse course Debugging

  1. Use the JavaScript Console to Check the Value of a Variable
  2. Understanding the Differences between the freeCodeCamp and Browser Console
  3. Use typeof to Check the Type of a Variable
  4. Catch Misspelled Variable and Function Names
  5. Catch Unclosed Parentheses, Brackets, Braces and Quotes
  6. Catch Mixed Usage of Single and Double Quotes
  7. Catch Use of Assignment Operator Instead of Equality Operator
  8. Catch Missing Open and Closing Parenthesis After a Function Call
  9. Catch Arguments Passed in the Wrong Order When Calling a Function
  10. Catch Off By One Errors When Using Indexing
  11. Use Caution When Reinitializing Variables Inside a Loop
  12. Prevent Infinite Loops with a Valid Terminal Condition

Basic Data Structures

Data can be stored and accessed in many ways. You already know some common JavaScript data structures — arrays and objects. In this Basic Data Structures course, you'll learn more about the differences between arrays and objects, and which to use in different situations. You'll also learn how to use helpful JS methods like splice() and Object.keys() to access and manipulate data.

Collapse courseBasic Data Structures

  1. Use an Array to Store a Collection of Data
  2. Access an Array's Contents Using Bracket Notation
  3. Add Items to an Array with push() and unshift()
  4. Remove Items from an Array with pop() and shift()
  5. Remove Items Using splice()
  6. Add Items Using splice()
  7. Copy Array Items Using slice()
  8. Copy an Array with the Spread Operator
  9. Combine Arrays with the Spread Operator
  10. Check For The Presence of an Element With indexOf()
  11. Iterate Through All an Array's Items Using For Loops
  12. Create complex multi-dimensional arrays
  13. Add Key-Value Pairs to JavaScript Objects
  14. Modify an Object Nested Within an Object
  15. Access Property Names with Bracket Notation
  16. Use the delete Keyword to Remove Object Properties
  17. Check if an Object has a Property
  18. Iterate Through the Keys of an Object with a for...in Statement
  19. Generate an Array of All Object Keys with Object.keys()
  20. Modify an Array Stored in an Object

Basic Algorithm Scripting

An algorithm is a series of step-by-step instructions that describe how to do something. To write an effective algorithm, it helps to break a problem down into smaller parts and think carefully about how to solve each part with code. In this course, you'll learn the fundamentals of algorithmic thinking by writing algorithms that do everything from converting temperatures to handling complex 2D arrays.

Collapse courseBasic Algorithm Scripting

  1. Convert Celsius to Fahrenheit
  2. Reverse a String
  3. Factorialize a Number
  4. Find the Longest Word in a String
  5. Return Largest Numbers in Arrays
  6. Confirm the Ending
  7. Repeat a String Repeat a String
  8. Truncate a String
  9. Finders Keepers
  10. Boo who
  11. Title Case a Sentence
  12. Slice and Splice
  13. Falsy Bouncer
  14. Where do I Belong
  15. Mutations
  16. Chunky Monkey

Object Oriented Programming

OOP, or Object Oriented Programming, is one of the major approaches to the software development process. In OOP, objects and classes organize code to describe things and what they can do.In this course, you'll learn the basic principles of OOP in JavaScript, including the this keyword, prototype chains, constructors, and inheritance.

Collapse courseObject Oriented Programming

  1. Create a Basic JavaScript Object
  2. Use Dot Notation to Access the Properties of an Object
  3. Create a Method on an Object
  4. Make Code More Reusable with the this Keyword
  5. Define a Constructor Function
  6. Use a Constructor to Create Objects
  7. Extend Constructors to Receive Arguments
  8. Verify an Object's Constructor with instanceof
  9. Understand Own Properties
  10. Use Prototype Properties to Reduce Duplicate Code
  11. Iterate Over All Properties
  12. Understand the Constructor Property
  13. Change the Prototype to a New Object
  14. Remember to Set the Constructor Property when Changing the Prototype
  15. Understand Where an Object’s Prototype Comes From
  16. Understand the Prototype Chain
  17. Use Inheritance So You Don't Repeat Yourself
  18. Inherit Behaviors from a Supertype
  19. Set the Child's Prototype to an Instance of the Parent
  20. Reset an Inherited Constructor Property
  21. Add Methods After Inheritance
  22. Override Inherited Methods
  23. Use a Mixin to Add Common Behavior Between Unrelated Objects
  24. Use Closure to Protect Properties Within an Object from Being Modified Externally
  25. Understand the Immediately Invoked Function Expression (IIFE)
  26. Use an IIFE to Create a Module

Functional Programming

Functional Programming is another popular approach to software development. In Functional Programming, code is organized into smaller, basic functions that can be combined to build complex programs. In this course, you'll learn the core concepts of Functional Programming including pure functions, how to avoid mutations, and how to write cleaner code with methods like .map() and .filter().

Collapse courseFunctional Programming

  1. Learn About Functional Programming
  2. Understand Functional Programming Terminology
  3. Understand the Hazards of Using Imperative Code
  4. Avoid Mutations and Side Effects Using Functional Programming
  5. Pass Arguments to Avoid External Dependence in a Function
  6. Refactor Global Variables Out of Functions
  7. Use the map Method to Extract Data from an Array
  8. Implement map on a Prototype
  9. Use the filter Method to Extract Data from an Array
  10. Implement the filter Method on a Prototype
  11. Return Part of an Array Using the slice Method
  12. Remove Elements from an Array Using slice Instead of splice
  13. Combine Two Arrays Using the concat Method
  14. Add Elements to the End of an Array Using concat Instead of push
  15. Use the reduce Method to Analyze Data
  16. Use Higher-Order Functions map, filter, or reduce to Solve a Complex Problem
  17. Sort an Array Alphabetically using the sort Method
  18. Return a Sorted Array Without Changing the Original Array
  19. Split a String into an Array Using the split Method
  20. Combine an Array into a String Using the join Method
  21. Apply Functional Programming to Convert Strings to URL Slugs
  22. Use the every Method to Check that Every Element in an Array Meets a Criteria
  23. Use the some Method to Check that Any Elements in an Array Meet a Criteria
  24. Introduction to Currying and Partial Application

Intermediate Algorithm Scripting Now that you know the basics of algorithmic thinking, along with OOP and Functional Programming, test your skills with the Intermediate Algorithm Scripting challenges.

Collapse courseIntermediate Algorithm Scripting

  1. Sum All Numbers in a Range
  2. Diff Two Arrays
  3. Seek and Destroy
  4. Wherefore art thou
  5. Spinal Tap Case
  6. Pig Latin
  7. Search and Replace
  8. DNA Pairing
  9. Missing letters
  10. Sorted Union
  11. Convert HTML Entities
  12. Sum All Odd Fibonacci Numbers
  13. Sum All Primes
  14. Smallest Common Multiple
  15. Drop it
  16. Steamroller
  17. Binary Agents
  18. Everything Be True
  19. Arguments Optional
  20. Make a Person
  21. Map the Debris

JavaScript Algorithms and Data Structures Projects This is it — time to put your new JavaScript skills to work. These projects are similar to the algorithm scripting challenges you've done before – just much more difficult. Complete these 5 JavaScript projects to earn the JavaScript Algorithms and Data Structures certification.

  1. Palindrome Checker
  2. Roman Numeral Converter
  3. Caesars Cipher
  4. Telephone Number Validator
  5. Cash Register

Credits

Author

  • This Github is done and maintain by Rajarshi SinhaRoy.

License

This project is licensed under the MIT License. See the LICENSE file for details.