├── 02_ES6 ├── README.md ├── index.html └── 01_compare_scopes_of_the_var_and_let_keywords.js ├── 01_Basic_JavaScript ├── 040_nest_one_array_within_another.js ├── 097_iterate_with_javaScript_for_loops.js ├── 099_count_backwards_with_a_for_loop.js ├── 106_generate_random_whole_numbers_with_javaScript.js ├── 014_divide_one_number_by_another_with_javascript.js ├── 019_divide_one_decimal_by_another_with_javaScript.js ├── 012_substract_one_number_from_another_with_javaScript.js ├── 013_multiply_two_numbers_with_javaScript.js ├── 096_iterate_with_javaScript_while_loops.js ├── 098_iterate_odd_numbers_with_a_for_loop.js ├── 103_replace_loops_using_recursion.js ├── 039_store_multiple_values_in_one_variable_using_javaScript_arrays.js ├── 011_add_two_numbers_with_javaScript.js ├── 018_multiply_two_decimals_with_javaScript.js ├── 042_modify_array_data_with_indexes.js ├── 108_use_the_parse_int_function.js ├── 015_increment_a_number_with_javaScript.js ├── 020_finding_a_remainder_in_javaScript.js ├── 100_iterate_through_an_array_with_a_for_loop.js ├── 016_decrement_a_number_with_javaScript.js ├── 089_delete_properties_from_a_javaScript_object.js ├── 049_functions.js ├── 005_initializing_variables_with_assignment_operator.js ├── 111_use_multiple_conditional_operators.js ├── 009_let_var_keywords.js ├── 107_generate_random_whole_numbers_within_a_range.js ├── 051_return_a_value_from_a_function_with_return.js ├── 056_assignment_with_a_returned_value.js ├── 102_iterate_with_javaScript_do_while_loops.js ├── 006_declare_string_variables.js ├── 022_compound_assignment_with_augmented_subtraction.js ├── 047_manipulate_arrays_with_unshift.js ├── 044_manipulate_arrays_with_push.js ├── 024_compound_assignment_with_augmented_division.js ├── 028_concatenating_strings_with_plus_operator.js ├── 101_nesting_loops.js ├── 003_storing_values_with_assignment_operator.js ├── 050_passing_values_to_functions_with_arguments.js ├── 058_understanding_boolean_values.js ├── 072_introducing_else_if_statements.js ├── 109_une_the_parseInt_function_with_a_radix.js ├── 023_compound_assignment_with_augmented_multiplication.js ├── 025_escaping_literal_quotes_in_strings.js ├── 105_generate_random_functions_with_javaScript.js ├── 080_returning_boolean_values_from_functions.js ├── 030_constructing_strings_with_variables.js ├── 054_local_global_scope_with_functions.js ├── 017_create_decimal_number_with_javaScript.js ├── 021_compound_assignment_with_augmented_addition.js ├── 060_comparison_with_the_equality_operator.js ├── 008_case_sensitivity_in_variables.js ├── 034_understanding_string_immutability.js ├── 088_add_new_properties_to_javaScript_object.js ├── 037_use_bracket_notation_to_find_the_nth_to_last_character_in_a_string.js ├── 031_appending_variables_to_string.js ├── 048_shopping_list.js ├── 094_accessing_nested_arrays.js ├── 071_introducing_else_statement.js ├── 087_updating_object_properties.js ├── 073_logical_order_in_if_else_statements.js ├── 081_return_early_pattern_for_functions.js ├── 036_use_bracket_notation_to_find_the_last_character_in_a_string.js ├── 032_find_length_of_a_string.js ├── 002_declare_javascript_variables.js ├── 035_use_bracket_notation_to_find_the_nth_character_in_a_string.js ├── 046_manipulate_arrays_with_shift.js ├── 055_understanding_undefined_value_returned_from_a_function.js ├── 083_build_javaScript_objects.js ├── 041_access_array_data_with_indexes.js ├── 069_comparisons_with_the_logical_and_operator.js ├── 086_accessing_object_properties_with_variables.js ├── 110_use_the_conditional_operator.js ├── 063_comparison_with_the_inequality_operator.js ├── 092_manipulating_complex_objects.js ├── 064_comparison_with_the_strict_inequality_operator.js ├── 043_access_multi_dimensional_array_with_indexes.js ├── 070_comparisons_with_the_logical_or_operator.js ├── 067_comparison_with_the_less_than_operator.js ├── 033_use_brack_notation_to_find_the_first_character_in_a_string.js ├── 084_accessing_object_properties_with_dot_notation.js ├── 045_manipulate_array_with_pop.js ├── 065_comparison_with_the_grater_than_operator.js ├── 062_practice_comparing_different_values.js ├── 093_accessing_nested_objects.js ├── 091_testing_objects_for_properties.js ├── 007_uninitialized_variables.js ├── 061_comparison_with_the_strict_equality_operator.js ├── 053_local_scope_and_functions.js ├── 004_assigning_the_value_of_one_variable_to_another.js ├── 074_chaining_if_else_statements.js ├── 029_concatenating_strings_with_the_plus_equals_operator.js ├── 026_quoting_strings_with_single_quotes.js ├── 066_comparison_with_the_grater_than_or_equal_to_operator.js ├── 085_accessing_object_properties_with_bracket_notation.js ├── 068_comparison_with_the_less_than_or_equal_to_operator.js ├── 038_word_blanks.js ├── 010_read_only_variable_const_keyword.js ├── 113_use_recursion_to_create_a_range_numbers.js ├── 001_comment_your_javascript_code.js ├── 057_stand_in_line.js ├── 027_escape_sequences_in_strings.js ├── 059_use_conditional_logic_with_if_statement.js ├── 077_adding_default_option_in_switch_statement.js ├── 076_selecting_from_many_options_with_switch_statements.js ├── 078_multiple_identical_options_in_switch_statements.js ├── 052_global_scope_and_functions.js ├── 112_use _recursion_to_create_a_countdown.js ├── 079_replacing_if_else_chains_with_switch.js ├── 075_golf_code.js ├── 090_using_objects_for_lookups.js ├── 082_counting_cards.js ├── 104_profile_lookup.js ├── 095_record_collection.js ├── index.html └── README.md └── README.md /02_ES6/README.md: -------------------------------------------------------------------------------- 1 | ### ES6 :heavy_check_mark: 2 | * [x] [Compare Scopes of the var and let Keywords](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/02_ES6/01_compare_scopes_of_the_var_and_let_keywords.js) 3 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/040_nest_one_array_within_another.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | // When you nest an array inside another it is called multi-dimensional array. 4 | 5 | // Task: Create a nested array called myArray. 6 | 7 | const myArray = [["Bulls", 23], ["White Sox", 45]]; 8 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/097_iterate_with_javaScript_for_loops.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | // Task: Use a for loop to push the values 1 through 5 onto myArray. 4 | 5 | const myArray = []; 6 | 7 | for(let i = 1; i <= 5; i++) { 8 | myArray.push(i); 9 | } 10 | 11 | console.log(myArray); 12 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/099_count_backwards_with_a_for_loop.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | // Task: Push the odd numbers from 9 through 1 to myArray using a for loop. 4 | 5 | const myArray = []; 6 | 7 | for(let i = 9; i >= 1; i--) { 8 | myArray.push(i); 9 | } 10 | 11 | console.log(myArray); 12 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/106_generate_random_whole_numbers_with_javaScript.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | // Task: Generate and return a random whole number between 0 and 9. 4 | 5 | function randomWholeNum() { 6 | return Math.floor(Math.random() * 10); 7 | } 8 | 9 | console.log(randomWholeNum()); 10 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/014_divide_one_number_by_another_with_javascript.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | // JavaScript uses the / symbol for division. 4 | 5 | /*Task: Change the 0 so that the quotient is equal to 2. 6 | const quotient = 66 / 0;*/ 7 | 8 | const quotient = 66 / 33; 9 | console.log(quotient); 10 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/019_divide_one_decimal_by_another_with_javaScript.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | /* 4 | Task: Change the 0.0 so that quotient will equal to 2.2. 5 | const quotient = 0.0 / 2.0; // Change this line 6 | */ 7 | 8 | const quotient = 4.4 / 2.0; 9 | console.log("Quotient", quotient) 10 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/012_substract_one_number_from_another_with_javaScript.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | // JavaScript uses the - symbol for subtraction. 4 | 5 | /* 6 | Task: Change the 0 so the difference is 12. 7 | const difference = 45 - 0;*/ 8 | 9 | const difference = 45 - 33; 10 | console.log(difference); 11 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/013_multiply_two_numbers_with_javaScript.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | // JavaScript uses the * symbol for multiplication of two numbers. 4 | 5 | /* 6 | Task: Change the 0 so that product will equal 80. 7 | const product = 8 * 0;*/ 8 | 9 | const product = 8 * 10; 10 | console.log(product); 11 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/096_iterate_with_javaScript_while_loops.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | // Task: Add the numbers 5 through 0 (inclusive) in descending order to myArray using a while loop. 4 | 5 | const myArray = []; 6 | let i = 5; 7 | 8 | while (i <= 5 && i >= 0) { 9 | myArray.push(i); 10 | i--; 11 | } 12 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/098_iterate_odd_numbers_with_a_for_loop.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | // Task: Push the odd numbers from 1 through 9 to myArray using a for loop. 4 | 5 | const myArray = []; 6 | 7 | for (let i = 1; i <= 9; i++) { 8 | if(i % 2 != 0) { 9 | myArray.push(i); 10 | } 11 | } 12 | 13 | console.log(myArray); 14 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/103_replace_loops_using_recursion.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | // Task: Write a recursive function, sum(arr, n), that returns the sum of the first n elements of an array arr. 4 | function sum(arr, n) { 5 | if (n <= 0) { 6 | return 0; 7 | } else { 8 | return sum(arr, n - 1) + arr[n - 1]; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/039_store_multiple_values_in_one_variable_using_javaScript_arrays.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | // With JavaScript array variables, we can store several pieces of data in one place. 4 | 5 | // Task: Modify the new array myArray so that it contains both a string and a number (in that order). 6 | 7 | const myArray = ["test", 13]; 8 | console.log("My array: ", myArray); 9 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/011_add_two_numbers_with_javaScript.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | // Number is a data type in JavaScript which represents numeric data. 4 | // JavaScript uses the + symbol as an addition operator when placed between two numbers. 5 | 6 | /*Task: Change the 0 so that sum will equal 20. 7 | const sum = 10 + 0;*/ 8 | 9 | const sum = 10 + 10; 10 | console.log(sum); 11 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/018_multiply_two_decimals_with_javaScript.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | // In JavaScript, you can also perform calculations with decimal numbers, just like whole numbers. 4 | 5 | /* 6 | Task: Change the 0.0 so that product will equal 5.0. 7 | 8 | const product = 2.0 * 0.0; 9 | 10 | */ 11 | 12 | const product = 2.0 * 2.5; 13 | console.log("Product", product); 14 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/042_modify_array_data_with_indexes.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | // Unlike strings, the entries of arrays are mutable and can be changed freely, even if the array was declared with const. 4 | 5 | // Task: Modify the data stored at index 0 of myArray to a value of 45. 6 | 7 | const myArray = [18, 64, 99]; 8 | myArray[0] = 45; 9 | console.log("Updated array", myArray); 10 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/108_use_the_parse_int_function.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | // The parseInt() function parses a string and returns an integer. 4 | 5 | // Task: Use parseInt() in the convertToInteger function so it converts the input string str into an integer, and returns it. 6 | 7 | function convertToInteger(str) { 8 | return parseInt(str); 9 | } 10 | 11 | convertToInteger("56"); 12 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/015_increment_a_number_with_javaScript.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | // Easily increment or add one to a variable with the ++ operator. 4 | 5 | /* 6 | Task: Change the code to use the ++ operator on myVar. 7 | 8 | let myVar = 87; 9 | // Only change code below this line 10 | myVar = myVar + 1; 11 | 12 | */ 13 | 14 | let myVar = 87; 15 | myVar++; 16 | console.log(myVar); 17 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/020_finding_a_remainder_in_javaScript.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | // The remainder operator % gives the remainder of the division of two numbers. 4 | 5 | /* 6 | Task: Set remainder equal to the remainder of 11 divided by 3 using the remainder (%) operator. 7 | 8 | const remainder = 0; 9 | */ 10 | 11 | const remainder = 11 % 3; 12 | console.log("Remainder", remainder); 13 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/100_iterate_through_an_array_with_a_for_loop.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | // Task: Declare and initialize a variable total to 0. Use a for loop to add the value of each element of the myArr array to total. 4 | 5 | const myArr = [2, 3, 4, 5, 6]; 6 | 7 | let total = 0; 8 | for (let i = 0; i < myArr.length; i++) { 9 | total += myArr[i]; 10 | } 11 | 12 | console.log(total); 13 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/016_decrement_a_number_with_javaScript.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | // Easily decrement or decrease a variable by one with the -- operator. 4 | 5 | /* 6 | Task: Change the code to use the -- operator on myVar. 7 | 8 | let myVar = 11; 9 | // Only change code below this line 10 | myVar = myVar - 1; 11 | 12 | */ 13 | 14 | 15 | let myVar = 11; 16 | myVar--; 17 | console.log(myVar); 18 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/089_delete_properties_from_a_javaScript_object.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | // Task: Delete the tails property from myDog. You may use either dot or bracket notation. 4 | 5 | // Setup 6 | const myDog = { 7 | "name": "Happy Coder", 8 | "legs": 4, 9 | "tails": 1, 10 | "friends": ["freeCodeCamp Campers"], 11 | "bark": "woof" 12 | }; 13 | 14 | delete myDog.tails; 15 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/049_functions.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | // In JavaScript, we can divide up our code into reusable parts called functions. 4 | 5 | /*Task: 6 | 1) Create a function called reusableFunction which prints the string Hi World to the dev console. 7 | 2) Call the function.*/ 8 | 9 | function reusableFunction () { 10 | console.log("Hi World"); 11 | } 12 | 13 | reusableFunction(); 14 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/005_initializing_variables_with_assignment_operator.js: -------------------------------------------------------------------------------- 1 | // Initializing Variables with the Assignment Operator 2 | 3 | /* 4 | It is common to initialize a variable to an initial value in the same line as it is declared. 5 | var myVar = 0; 6 | Creates a new variable called myVar and assigns it an initial value of 0.*/ 7 | 8 | // Task: Define a variable a with var and initialize it to a value of 9./ 9 | var a = 9; 10 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/111_use_multiple_conditional_operators.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | // Task: In the checkSign function, use multiple conditional operators - following the recommended format used in findGreaterOrEqual - to check if a number is positive, negative or zero. The function should return positive, negative or zero. 4 | function checkSign(num) { 5 | return num < 0 ? "negative" : (num > 0 ? "positive" : "zero") 6 | } 7 | 8 | checkSign(10); 9 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/009_let_var_keywords.js: -------------------------------------------------------------------------------- 1 | // Differences Between the var and let Keywords 2 | 3 | // Declared variables with the var keyword can easily be overwritten 4 | // So unlike var, when you use let, a variable with the same name can only be declared once. 5 | 6 | // Update the code, so it only uses the let keyword. 7 | // var catName = "Oliver"; 8 | // var catSound = "Meow!"; 9 | 10 | let catName = "Oliver"; 11 | let catSound = "Meow!"; 12 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/107_generate_random_whole_numbers_within_a_range.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | // Create a function called randomRange that takes a range myMin and myMax and returns a random whole number that's greater than or equal to myMin, and is less than or equal to myMax, inclusive. 4 | 5 | function randomRange(myMin, myMax) { 6 | return Math.floor(Math.random() * (myMax - myMin + 1)) + myMin 7 | } 8 | 9 | console.log(randomRange(7, 15)); 10 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/051_return_a_value_from_a_function_with_return.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | // We can pass values into a function with arguments. You can use a return statement to send a value back out of a function. 4 | 5 | // Task: Create a function timesFive that accepts one argument, multiplies it by 5, and returns the new value. 6 | 7 | function timesFive(arg) { 8 | return 5 * arg; 9 | } 10 | 11 | timesFive(5); 12 | console.log("Result: ", timesFive(5)); 13 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/056_assignment_with_a_returned_value.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | // We can take the return value of a function and assign it to a variable. 4 | 5 | // Task: Call the processArg function with an argument of 7 and assign its return value to the variable processed. 6 | 7 | // Setup 8 | let processed = 0; 9 | 10 | function processArg(num) { 11 | return (num + 3) / 5; 12 | } 13 | 14 | processed = processArg(7); 15 | console.log("Processed", processed); 16 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/102_iterate_with_javaScript_do_while_loops.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | // Task: Change the while loop in the code to a do...while loop so the loop will push only the number 10 to myArray, and i will be equal to 11 when your code has finished running. 4 | 5 | // Setup 6 | const myArray = []; 7 | let i = 10; 8 | 9 | // Only change code below this line 10 | do { 11 | myArray.push(i); 12 | } 13 | while (i < 5) { 14 | i++; 15 | } 16 | 17 | console.log(myArray) 18 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/006_declare_string_variables.js: -------------------------------------------------------------------------------- 1 | /* 2 | Declare String Variables 3 | var myName = "your name"; 4 | "your name" is called a string literal. A string literal, or string, is a series of zero or more characters enclosed in single or double quotes.*/ 5 | 6 | // Task: Create two new string variables: myFirstName and myLastName and assign them the values of your first and last name, respectively. 7 | 8 | var myFirstName = "Some Kind of"; 9 | var myLastName = "Wallflower"; 10 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/022_compound_assignment_with_augmented_subtraction.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | // -= operator subtracts a number from a variable. 4 | /* 5 | 6 | Task: Convert the assignments for a, b, and c to use the -= operator. 7 | 8 | let a = 11; 9 | let b = 9; 10 | let c = 3; 11 | 12 | // Only change code below this line 13 | a = a - 6; 14 | b = b - 15; 15 | c = c - 1; 16 | 17 | */ 18 | 19 | let a = 11; 20 | let b = 9; 21 | let c = 3; 22 | a -= 6; 23 | b -= 15; 24 | c -= 1; 25 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/047_manipulate_arrays_with_unshift.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | // .unshift() works exactly like .push(), but instead of adding the element at the end of the array, unshift() adds the element at the beginning of the array. 4 | 5 | // Task: Add ["Paul", 35] to the beginning of the myArray variable using unshift(). 6 | 7 | // Setup 8 | const myArray = [["John", 23], ["dog", 3]]; 9 | myArray.shift(); 10 | myArray.unshift(["Paul", 35]); 11 | console.log("My array: ", myArray); 12 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/044_manipulate_arrays_with_push.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | // An easy way to append data to the end of an array is via the push() function. 4 | // .push() takes one or more parameters and "pushes" them onto the end of the array. 5 | 6 | // Task: Push ["dog", 3] onto the end of the myArray variable. 7 | 8 | 9 | // Setup 10 | const myArray = [["John", 23], ["cat", 2]]; 11 | // Only change code below this line 12 | myArray.push(["dog", 3]); 13 | console.log("My array: ", myArray); 14 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/024_compound_assignment_with_augmented_division.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | // The /= operator divides a variable by another number. 4 | 5 | /* 6 | Task: Convert the assignments for a, b, and c to use the /= operator. 7 | 8 | let a = 48; 9 | let b = 108; 10 | let c = 33; 11 | 12 | // Only change code below this line 13 | a = a / 12; 14 | b = b / 4; 15 | c = c / 11; 16 | 17 | */ 18 | 19 | let a = 48; 20 | let b = 108; 21 | let c = 33; 22 | 23 | a /= 12; 24 | b /= 4; 25 | c /= 11; 26 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/028_concatenating_strings_with_plus_operator.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | // In JavaScript, when the + operator is used with a String value, it is called the concatenation operator. 4 | // You can build a new string out of other strings by concatenating them together. 5 | 6 | // Task: Build myStr from the strings This is the start. and This is the end. using the + operator. Be sure to include a space between the two strings. 7 | 8 | const myStr = "This is the start." + " " + "This is the end."; 9 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/101_nesting_loops.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | // Task: Modify function multiplyAll so that it returns the product of all the numbers in the sub-arrays of arr. 4 | 5 | function multiplyAll(arr) { 6 | let product = 1; 7 | for(let i = 0; i < arr.length; i++) { 8 | for(let j = 0; j < arr[i].length; j++) { 9 | product *= arr[i][j]; 10 | } 11 | } 12 | return product; 13 | } 14 | 15 | multiplyAll([[1, 2], [3, 4], [5, 6, 7]]); 16 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/003_storing_values_with_assignment_operator.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | // Storing Values with the Assignment Operator 4 | 5 | // In JavaScript, you can store a value in a variable with the assignment operator (=). 6 | 7 | /* First, this code creates a variable named myVar. 8 | Then, the code assigns 5 to myVar. Now, if myVar appears again in the code, the program will treat it as if it is 5. 9 | var myVar; 10 | myVar = 5; */ 11 | 12 | // Task: Assign the value 7 to variable a. 13 | 14 | var a = 7; 15 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/050_passing_values_to_functions_with_arguments.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | // Parameters are variables that act as placeholders for the values that are to be input to a function when it is called 4 | 5 | /* 6 | Task: 1) Create a function called functionWithArgs that accepts two arguments and outputs their sum to the dev console. 7 | 2) Call the function with two numbers as arguments.*/ 8 | 9 | function functionWithArgs(arg1, arg2) { 10 | console.log(arg1 + arg2) 11 | } 12 | 13 | functionWithArgs(2, 3); 14 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/058_understanding_boolean_values.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | // Booleans may only be one of two values: true or false. They are basically little on-off switches, where true is on and false is off. 4 | 5 | // Task: Modify the welcomeToBooleans function so that it returns true instead of false when the run button is clicked. 6 | 7 | 8 | function welcomeToBooleans() { 9 | // return false; 10 | return true; 11 | } 12 | 13 | console.log("Welcome to boolean return function value is: ", welcomeToBooleans()); 14 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/072_introducing_else_if_statements.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | // If you have multiple conditions that need to be addressed, you can chain if statements together with else if statements. 4 | 5 | 6 | // Task: Convert the logic to use else if statements. 7 | 8 | function testElseIf(val) { 9 | if (val > 10) { 10 | return "Greater than 10"; 11 | } else if (val < 5) { 12 | return "Smaller than 5"; 13 | } else { 14 | return "Between 5 and 10"; 15 | } 16 | } 17 | 18 | testElseIf(7); 19 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/109_une_the_parseInt_function_with_a_radix.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | // The parseInt() function parses a string and returns an integer. It takes a second argument for the radix, which specifies the base of the number in the string. The radix can be an integer between 2 and 36. 4 | 5 | // Task: Use parseInt() in the convertToInteger function so it converts a binary number to an integer and returns it. 6 | 7 | function convertToInteger(str) { 8 | return parseInt(str, 2); 9 | } 10 | 11 | convertToInteger("10011"); 12 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/023_compound_assignment_with_augmented_multiplication.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | // The *= operator multiplies a variable by a number. 4 | 5 | /* 6 | Task: Convert the assignments for a, b, and c to use the *= operator. 7 | 8 | let a = 5; 9 | let b = 12; 10 | let c = 4.6; 11 | 12 | // Only change code below this line 13 | a = a * 5; 14 | b = 3 * b; 15 | c = c * 10; 16 | 17 | */ 18 | 19 | let a = 5; 20 | let b = 12; 21 | let c = 4.6; 22 | 23 | // Only change code below this line 24 | a *= 5; 25 | b *= 3; 26 | c *= 10; 27 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/025_escaping_literal_quotes_in_strings.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | // In JavaScript, you can escape a quote from considering it as an end of string quote by placing a backslash (\) in front of the quote. 4 | 5 | /* 6 | Task: Use backslashes to assign a string to the myStr variable so that if you were to print it to the console, you would see: 7 | I am a "double quoted" string inside "double quotes".*/ 8 | 9 | const myStr = "I am a \"double quoted\" string inside \"double quotes\"."; 10 | console.log("String", myStr); 11 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/105_generate_random_functions_with_javaScript.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | /* 4 | Random numbers are useful for creating random behavior. 5 | JavaScript has a Math.random() function that generates a random decimal number between 0 (inclusive) and 1 (exclusive). 6 | Thus Math.random() can return a 0 but never return a 1.*/ 7 | 8 | // Task : Change randomFraction to return a random number instead of returning 0. 9 | 10 | function randomFraction() { 11 | return Math.random(); 12 | } 13 | 14 | console.log(randomFraction()); 15 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/080_returning_boolean_values_from_functions.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | /* 4 | Task: Fix the function isLess to remove the if/else statements. 5 | 6 | function isLess(a, b) { 7 | // Only change code below this line 8 | if (a < b) { 9 | return true; 10 | } else { 11 | return false; 12 | } 13 | // Only change code above this line 14 | } 15 | 16 | isLess(10, 15);*/ 17 | 18 | 19 | function isLess(a, b) { 20 | return a < b; 21 | } 22 | 23 | isLess(10, 15); 24 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/030_constructing_strings_with_variables.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | // By using the concatenation operator (+), you can insert one or more variables into a string you're building. 4 | 5 | /* 6 | Task: Set myName to a string equal to your name and build myStr with myName between the strings My name is and and I am well! 7 | 8 | const myName = ""; 9 | const myStr = ""; 10 | 11 | */ 12 | 13 | const myName = "Some kind of Wallflower"; 14 | const myStr = "My name is" + myName + "and I am well!"; 15 | 16 | console.log("My string", myStr); 17 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/054_local_global_scope_with_functions.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | // It is possible to have both local and global variables with the same name. When you do this, the local variable takes precedence over the global variable. 4 | 5 | // Task: Add a local variable to myOutfit function to override the value of outerWear with the string sweater. 6 | 7 | // Setup 8 | const outerWear = "T-Shirt"; 9 | 10 | function myOutfit() { 11 | const outerWear = "sweater" 12 | return outerWear; 13 | } 14 | 15 | console.log("Result", myOutfit()); 16 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/017_create_decimal_number_with_javaScript.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | // We can store decimal numbers in variables too. Decimal numbers are sometimes referred to as floating point numbers or floats. 4 | 5 | /*Task: Create a variable myDecimal and give it a decimal value with a fractional part (e.g. 5.7). 6 | 7 | const ourDecimal = 5.7; 8 | // Only change code below this line 9 | 10 | */ 11 | 12 | const ourDecimal = 5.7; 13 | const myDecimal = 13.27; 14 | 15 | console.log("Our Decimal", ourDecimal); 16 | console.log("My Decimal", myDecimal); 17 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/021_compound_assignment_with_augmented_addition.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | // Operators can do both a mathematical operation and assignment in one step. 4 | // One such operator is the += operator. 5 | 6 | /* 7 | Task: Convert the assignments for a, b, and c to use the += operator. 8 | 9 | let a = 3; 10 | let b = 17; 11 | let c = 12; 12 | 13 | // Only change code below this line 14 | a = a + 12; 15 | b = 9 + b; 16 | c = c + 7; 17 | 18 | */ 19 | 20 | let a = 3; 21 | let b = 17; 22 | let c = 12; 23 | 24 | a += 12; 25 | b += 9; 26 | c += 7; 27 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/060_comparison_with_the_equality_operator.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | // There are many comparison operators in JavaScript. All of these operators return a boolean true or false value. 4 | 5 | // Task: Add the equality operator to the indicated line so that the function will return the string Equal when val is equivalent to 12. 6 | 7 | // Setup 8 | function testEqual(val) { 9 | if (val == 12) { 10 | return "Equal"; 11 | } 12 | return "Not Equal"; 13 | } 14 | 15 | console.log(testEqual(10)); 16 | console.log(testEqual(12)); 17 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/008_case_sensitivity_in_variables.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | // All variables and function names are case sensitive 4 | 5 | // Task: Modify the existing declarations and assignments so their names use camelCase. 6 | /* 7 | var StUdLyCapVaR; 8 | var properCamelCase; 9 | var TitleCaseOver; 10 | 11 | STUDLYCAPVAR = 10; 12 | PRoperCAmelCAse = "A String"; 13 | tITLEcASEoVER = 9000;*/ 14 | 15 | var studlyCapVar; 16 | var properCamelCase; 17 | var titleCaseOver; 18 | 19 | studlyCapVar = 10; 20 | properCamelCase = "A String"; 21 | titleCaseOver = 9000; 22 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/034_understanding_string_immutability.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | // In JavaScript, String values are immutable, which means that they cannot be altered once created. 4 | 5 | /* 6 | Task: Correct the assignment to myStr so it contains the string value of Hello World using the approach shown in the example above. 7 | 8 | // Setup 9 | let myStr = "Jello World"; 10 | 11 | // Only change code below this line 12 | myStr[0] = "H"; // Change this line 13 | // Only change code above this line 14 | 15 | */ 16 | 17 | let myStr = "Jello World"; 18 | myStr= "Hello World"; 19 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/088_add_new_properties_to_javaScript_object.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | // You can add new properties to existing JavaScript objects the same way you would modify them. 4 | 5 | // Task: Add a bark property to myDog and set it to a dog sound, such as "woof". You may use either dot or bracket notation. 6 | 7 | const myDog = { 8 | "name": "Happy Coder", 9 | "legs": 4, 10 | "tails": 1, 11 | "friends": ["freeCodeCamp Campers"] 12 | }; 13 | 14 | myDog.bark = "Bow-wow"; 15 | console.log("The value of bark property in myDog object is: ", myDog.bark); 16 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/037_use_bracket_notation_to_find_the_nth_to_last_character_in_a_string.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | /* 4 | Task: Use bracket notation to find the second-to-last character in the lastName string. 5 | 6 | // Setup 7 | const lastName = "Lovelace"; 8 | 9 | // Only change code below this line 10 | const secondToLastLetterOfLastName = lastName; // Change this line 11 | 12 | */ 13 | 14 | const lastName = "Lovelace"; 15 | const secondToLastLetterOfLastName = lastName[lastName.length - 2]; 16 | console.log("Second to last letter of last name is: ", secondToLastLetterOfLastName); 17 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/031_appending_variables_to_string.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | // Appending Variables to Strings 4 | 5 | // Just as we can build a string over multiple lines out of string literals, we can also append variables to a string using the plus equals (+=) operator. 6 | 7 | /*Task: Set someAdjective to a string of at least 3 characters and append it to myStr using the += operator. 8 | 9 | const someAdjective = ""; 10 | let myStr = "Learning to code is "; 11 | 12 | */ 13 | 14 | const someAdjective = "cool"; 15 | let myStr = "Learning to code is "; 16 | myStr += someAdjective; 17 | console.log("My String", myStr); 18 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/048_shopping_list.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | // Create a shopping list in the variable myList. The list should be a multi-dimensional array containing several sub-arrays. 4 | // The first element in each sub-array should contain a string with the name of the item. The second element should be a number representing the quantity i.e. 5 | // ["Chocolate Bar", 15] 6 | // There should be at least 5 sub-arrays in the list. 7 | 8 | const myList = []; 9 | myList.push(["Chocolate Bar", 15]); 10 | myList.push(["Pasta", 3]); 11 | myList.push(["Coca", 6]); 12 | myList.push(["Bread", 1]); 13 | myList.push(["Eggs", 12]); 14 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/094_accessing_nested_arrays.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | // Task: Using dot and bracket notation, set the variable secondTree to the second item in the trees list from the myPlants object. 4 | 5 | const myPlants = [ 6 | { 7 | type: "flowers", 8 | list: [ 9 | "rose", 10 | "tulip", 11 | "dandelion" 12 | ] 13 | }, 14 | { 15 | type: "trees", 16 | list: [ 17 | "fir", 18 | "pine", 19 | "birch" 20 | ] 21 | } 22 | ]; 23 | 24 | const secondTree = myPlants[1].list[1]; 25 | console.log(secondTree); 26 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/071_introducing_else_statement.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | /* 4 | When a condition for an if statement is true, the block of code following it is executed. What about when that condition is false? Normally nothing would happen. 5 | With an else statement, an alternate block of code can be executed.*/ 6 | 7 | // Task: Combine the if statements into a single if/else statement. 8 | 9 | function testElse(val) { 10 | let result = ""; 11 | if (val > 5) { 12 | result = "Bigger than 5"; 13 | } 14 | else { 15 | result = "5 or Smaller"; 16 | } 17 | return result; 18 | } 19 | 20 | testElse(4); 21 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/087_updating_object_properties.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | // After you've created a JavaScript object, you can update its properties at any time just like you would update any other variable. You can use either dot or bracket notation to update. 4 | 5 | // Task: Update the myDog object's name property. Let's change her name from Coder to Happy Coder. You can use either dot or bracket notation. 6 | 7 | const myDog = { 8 | "name": "Coder", 9 | "legs": 4, 10 | "tails": 1, 11 | "friends": ["freeCodeCamp Campers"] 12 | }; 13 | 14 | myDog["name"] = "Happy Coder"; 15 | console.log("My dog name is: ", myDog["name"]); 16 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/073_logical_order_in_if_else_statements.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | /* 4 | Order is important in if, else if statements. 5 | The function is executed from top to bottom so you will want to be careful of what statement comes first. 6 | */ 7 | 8 | // Task: Change the order of logic in the function so that it will return the correct statements in all cases. 9 | 10 | function orderMyLogic(val) { 11 | if (val < 5) { 12 | return "Less than 5"; 13 | } else if (val < 10) { 14 | return "Less than 10"; 15 | } else { 16 | return "Greater than or equal to 10"; 17 | } 18 | } 19 | 20 | orderMyLogic(7); 21 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/081_return_early_pattern_for_functions.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | /* 4 | Task: Modify the function abTest so that if a or b are less than 0 the function will immediately exit with a value of undefined. 5 | 6 | // Setup 7 | function abTest(a, b) { 8 | // Only change code below this line 9 | 10 | 11 | 12 | // Only change code above this line 13 | 14 | return Math.round(Math.pow(Math.sqrt(a) + Math.sqrt(b), 2)); 15 | } 16 | 17 | abTest(2,2);*/ 18 | 19 | function abTest(a, b) { 20 | if( a < 0 || b < 0) return; 21 | return Math.round(Math.pow(Math.sqrt(a) + Math.sqrt(b), 2)); 22 | } 23 | 24 | abTest(2,2); 25 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/036_use_bracket_notation_to_find_the_last_character_in_a_string.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | // In order to get the last letter of a string, you can subtract one from the string's length. 4 | 5 | /* 6 | 7 | Task: Use bracket notation to find the last character in the lastName variable. 8 | 9 | // Setup 10 | const lastName = "Lovelace"; 11 | 12 | // Only change code below this line 13 | const lastLetterOfLastName = lastName; // Change this line 14 | 15 | */ 16 | 17 | const lastName = "Lovelace"; 18 | const lastLetterOfLastName = lastName[lastName.length - 1]; 19 | console.log("Last letter of last name is: ", lastLetterOfLastName); 20 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/032_find_length_of_a_string.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | // You can find the length of a String value by writing .length after the string variable or string literal. 4 | /* 5 | 6 | Task: Use the .length property to count the number of characters in the lastName variable and assign it to lastNameLength. 7 | 8 | // Setup 9 | let lastNameLength = 0; 10 | const lastName = "Lovelace"; 11 | 12 | // Only change code below this line 13 | lastNameLength = lastName; 14 | 15 | */ 16 | 17 | 18 | let lastNameLength = 0; 19 | const lastName = "Lovelace"; 20 | lastNameLength = lastName.length; 21 | console.log("Last name length is: ", lastNameLength); 22 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/002_declare_javascript_variables.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /* 3 | JavaScript provides eight different data types which are: 4 | 5 | undefined, 6 | null, 7 | boolean, 8 | string, 9 | symbol, 10 | bigint, 11 | number, 12 | object*/ 13 | 14 | /* Variables are similar to the x and y variables you use in mathematics, which means they're a simple name to represent the data we want to refer to. 15 | 'Computer variables differ from mathematical variables in that they can store different values at different times. 16 | We tell JavaScript to create or declare a variable by putting the keyword var 17 | */ 18 | 19 | var myName; 20 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/035_use_bracket_notation_to_find_the_nth_character_in_a_string.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | // You can also use bracket notation to get the character at other positions within a string 4 | 5 | /* 6 | Task: Let's try to set thirdLetterOfLastName to equal the third letter of the lastName variable using bracket notation. 7 | 8 | // Setup 9 | const lastName = "Lovelace"; 10 | 11 | // Only change code below this line 12 | const thirdLetterOfLastName = lastName; // Change this line 13 | 14 | */ 15 | 16 | const lastName = "Lovelace"; 17 | const thirdLetterOfLastName = lastName[2]; 18 | console.log("Third letter of last name: ", thirdLetterOfLastName); 19 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/046_manipulate_arrays_with_shift.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | // pop() always removes the last element of an array. What if you want to remove the first? 4 | // That's where .shift() comes in. It works just like .pop(), except it removes the first element instead of the last. 5 | 6 | 7 | // Task: Use the .shift() function to remove the first item from myArray and assign the "shifted off" value to a new variable, removedFromMyArray. 8 | 9 | // Setup 10 | const myArray = [["John", 23], ["dog", 3]]; 11 | // Only change code below this line 12 | const removedFromMyArray = myArray.shift(); 13 | console.log("Shifted value is: ", removedFromMyArray); 14 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/055_understanding_undefined_value_returned_from_a_function.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | // A function can include the return statement but it does not have to. 4 | // In the case that the function doesn't have a return statement, when you call it, the function processes the inner code but the returned value is undefined. 5 | 6 | // Task: Create a function addFive without any arguments. This function adds 5 to the sum variable, but its returned value is undefined. 7 | 8 | // Setup 9 | let sum = 0; 10 | function addThree() { 11 | sum = sum + 3; 12 | } 13 | 14 | function addFive() { 15 | sum += 5; 16 | } 17 | 18 | addThree(); 19 | addFive(); 20 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/083_build_javaScript_objects.js: -------------------------------------------------------------------------------- 1 | "use strict" 2 | 3 | // Objects are similar to arrays, except that instead of using indexes to access and modify their data, you access the data in objects through what are called properties. 4 | 5 | /* 6 | Task: Make an object that represents a dog called myDog which contains the properties name (a string), legs, tails and friends. 7 | You can set these object properties to whatever values you want, as long as name is a string, legs and tails are numbers, and friends is an array.*/ 8 | 9 | const myDog = { 10 | name: "Max", 11 | legs: 4, 12 | tails: 1, 13 | friends: ["Joe", "Ana", "Bob"] 14 | }; 15 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/041_access_array_data_with_indexes.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | // We can access the data inside arrays using indexes 4 | // Array indexes are written in the same bracket notation that strings use, except that instead of specifying a character, they are specifying an entry in the array. 5 | // Like strings, arrays use zero-based indexing, so the first element in an array has an index of 0. 6 | 7 | 8 | // Task: Create a variable called myData and set it to equal the first value of myArray using bracket notation. 9 | 10 | const myArray = [50, 60, 70]; 11 | const myData = myArray[0]; 12 | 13 | console.log("Fist element of: " + myArray + "is: " + myData); 14 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/069_comparisons_with_the_logical_and_operator.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | // Sometimes you will need to test more than one thing at a time. The logical and operator (&&) returns true if and only if the operands to the left and right of it are true. 4 | 5 | // Task: Replace the two if statements with one statement, using the && operator, which will return the string Yes if val is less than or equal to 50 and greater than or equal to 25. 6 | // Otherwise, will return the string No. 7 | 8 | function testLogicalAnd(val) { 9 | if (val <= 50 && val >= 25) { 10 | return "Yes"; 11 | } 12 | return "No"; 13 | } 14 | 15 | testLogicalAnd(10); 16 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/086_accessing_object_properties_with_variables.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | // Another use of bracket notation on objects is to access a property which is stored as the value of a variable. This can be very useful for iterating through an object's properties or when accessing a lookup table. 4 | 5 | // Task: Set the playerNumber variable to 16. Then, use the variable to look up the player's name and assign it to player. 6 | 7 | // Setup 8 | const testObj = { 9 | 12: "Namath", 10 | 16: "Montana", 11 | 19: "Unitas" 12 | }; 13 | 14 | const playerNumber = 16; 15 | const player = testObj[playerNumber]; 16 | 17 | console.log("Player is: ", player); 18 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/110_use_the_conditional_operator.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | /* 4 | The conditional operator, also called the ternary operator, can be used as a one line if-else expression. 5 | The syntax is a ? b : c, where a is the condition, b is the code to run when the condition returns true, and c is the code to run when the condition returns false.*/ 6 | 7 | 8 | // Task: Use the conditional operator in the checkEqual function to check if two numbers are equal or not. The function should return either the string Equal or the string Not Equal. 9 | 10 | function checkEqual(a, b) { 11 | return a === b ? "Equal" : "Not Equal" 12 | } 13 | 14 | checkEqual(1, 2); 15 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/063_comparison_with_the_inequality_operator.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | // The inequality operator (!=) is the opposite of the equality operator. 4 | // It means not equal and returns false where equality would return true and vice versa. Like the equality operator, the inequality operator will convert data types of values while comparing. 5 | 6 | 7 | // Task: Add the inequality operator != in the if statement so that the function will return the string Not Equal when val is not equivalent to 99. 8 | 9 | function testNotEqual(val) { 10 | if (val != 99) { 11 | return "Not Equal"; 12 | } 13 | return "Equal"; 14 | } 15 | 16 | testNotEqual(10); 17 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/092_manipulating_complex_objects.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | // Task: Add a new album to the myMusic array. Add artist and title strings, release_year number, and a formats array of strings. 4 | 5 | const myMusic = [ 6 | { 7 | "artist": "Billy Joel", 8 | "title": "Piano Man", 9 | "release_year": 1973, 10 | "formats": [ 11 | "CD", 12 | "8T", 13 | "LP" 14 | ], 15 | "gold": true 16 | } 17 | ]; 18 | myMusic.push({ 19 | "artist": "Anson", 20 | "title": "Emerald Eyes", 21 | "release_year": 2019, 22 | "formats": [ 23 | "CD", 24 | "LP" 25 | ], 26 | }) 27 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/064_comparison_with_the_strict_inequality_operator.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | // The strict inequality operator (!==) is the logical opposite of the strict equality operator. It means "Strictly Not Equal" and returns false where strict equality would return true and vice versa. 4 | // The strict inequality operator will not convert data types. 5 | 6 | // Task: Add the strict inequality operator to the if statement so the function will return the string Not Equal when val is not strictly equal to 17 7 | 8 | function testStrictNotEqual(val) { 9 | if (val !== 17) { 10 | return "Not Equal"; 11 | } 12 | return "Equal"; 13 | } 14 | 15 | testStrictNotEqual(10); 16 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/043_access_multi_dimensional_array_with_indexes.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | // One way to think of a multi-dimensional array, is as an array of arrays. 4 | // When you use brackets to access your array, the first set of brackets refers to the entries in the outer-most (the first level) array, and each additional pair of brackets refers to the next level of entries inside. 5 | 6 | 7 | // Task: Using bracket notation select an element from myArray such that myData is equal to 8. 8 | 9 | const myArray = [ 10 | [1, 2, 3], 11 | [4, 5, 6], 12 | [7, 8, 9], 13 | [[10, 11, 12], 13, 14], 14 | ]; 15 | 16 | const myData = myArray[2][1]; 17 | console.log("My data: ", myData); 18 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/070_comparisons_with_the_logical_or_operator.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | /* 4 | The logical or operator (||) returns true if either of the operands is true. 5 | Otherwise, it returns false. 6 | The logical or operator is composed of two pipe symbols: (||). 7 | This can typically be found between your Backspace and Enter keys.*/ 8 | 9 | 10 | // Task: which returns the string Outside if val is not between 10 and 20, inclusive. Otherwise, return the string Inside. 11 | 12 | function testLogicalOr(val) { 13 | // Only change code below this line 14 | 15 | if (val < 10 || val > 20) { 16 | return "Outside"; 17 | } 18 | return "Inside"; 19 | } 20 | 21 | testLogicalOr(15); 22 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/067_comparison_with_the_less_than_operator.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | /* 4 | The less than operator (<) compares the values of two numbers. 5 | If the number to the left is less than the number to the right, it returns true. Otherwise, it returns false. 6 | Like the equality operator, the less than operator converts data types while comparing.*/ 7 | 8 | 9 | // Task: Add the less than operator to the indicated lines so that the return statements make sense. 10 | 11 | function testLessThan(val) { 12 | if (val < 25) { 13 | return "Under 25"; 14 | } 15 | if (val < 55) { 16 | return "Under 55"; 17 | } 18 | return "55 or Over"; 19 | } 20 | 21 | testLessThan(10); 22 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/033_use_brack_notation_to_find_the_first_character_in_a_string.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | // You can get the value of the first letter of the string by using string[0] 4 | 5 | 6 | /* 7 | 8 | Task: Use bracket notation to find the first character in the lastName variable and assign it to firstLetterOfLastName. 9 | 10 | // Setup 11 | let firstLetterOfLastName = ""; 12 | const lastName = "Lovelace"; 13 | 14 | // Only change code below this line 15 | firstLetterOfLastName = lastName; // Change this line 16 | 17 | */ 18 | 19 | let firstLetterOfLastName = ""; 20 | const lastName = "Lovelace"; 21 | firstLetterOfLastName = lastName[0]; 22 | console.log("First letter of last name: ", firstLetterOfLastName); 23 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/084_accessing_object_properties_with_dot_notation.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | // There are two ways to access the properties of an object: dot notation (.) and bracket notation ([]), similar to an array. 4 | 5 | // Task: Read in the property values of testObj using dot notation. Set the variable hatValue equal to the object's property hat and set the variable shirtValue equal to the object's property shirt. 6 | 7 | // Setup 8 | const testObj = { 9 | "hat": "ballcap", 10 | "shirt": "jersey", 11 | "shoes": "cleats" 12 | }; 13 | 14 | const hatValue = testObj.hat; 15 | const shirtValue = testObj.shirt; 16 | 17 | console.log("Hat value is: ", hatValue); 18 | console.log("Shirt value is: ", shirtValue); 19 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/045_manipulate_array_with_pop.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | // Another way to change the data in an array is with the .pop() function. 4 | // .pop() is used to pop a value off of the end of an array. We can store this popped off value by assigning it to a variable. In other words, .pop() removes the last element from an array and returns that element. 5 | 6 | // Task: Use the .pop() function to remove the last item from myArray and assign the popped off value to a new variable, removedFromMyArray. 7 | 8 | // Setup 9 | const myArray = [["John", 23], ["cat", 2]]; 10 | // Only change code below this line 11 | const removedFromMyArray = myArray.pop(); 12 | console.log("'Element removed frm the array is:", removedFromMyArray); 13 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/065_comparison_with_the_grater_than_operator.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | /* 4 | The greater than operator (>) compares the values of two numbers. 5 | If the number to the left is greater than the number to the right, it returns true. Otherwise, it returns false. 6 | Like the equality operator, the greater than operator will convert data types of values while comparing.*/ 7 | 8 | // Task: Add the greater than operator to the indicated lines so that the return statements make sense. 9 | 10 | function testGreaterThan(val) { 11 | if (val > 100) { 12 | return "Over 100"; 13 | } 14 | if (val > 10) { 15 | return "Over 10"; 16 | } 17 | return "10 or Under"; 18 | } 19 | 20 | testGreaterThan(10); 21 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/062_practice_comparing_different_values.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | // If the values being compared are not of the same type, the equality operator will perform a type conversion, and then evaluate the values. 4 | // However, the strict equality operator will compare both the data type and value as-is, without converting one type to the other. 5 | 6 | 7 | // Task: The compareEquality function in the editor compares two values using the equality operator. Modify the function so that it returns the string Equal only when the values are strictly equal. 8 | 9 | function compareEquality(a, b) { 10 | if (a === b) { 11 | return "Equal"; 12 | } 13 | return "Not Equal"; 14 | } 15 | 16 | compareEquality(10, "10"); 17 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/093_accessing_nested_objects.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | // The sub-properties of objects can be accessed by chaining together the dot or bracket notation. 4 | 5 | // Task: Access the myStorage object and assign the contents of the glove box property to the gloveBoxContents variable. Use dot notation for all properties where possible, otherwise use bracket notation. 6 | 7 | const myStorage = { 8 | "car": { 9 | "inside": { 10 | "glove box": "maps", 11 | "passenger seat": "crumbs" 12 | }, 13 | "outside": { 14 | "trunk": "jack" 15 | } 16 | } 17 | }; 18 | 19 | const gloveBoxContents = myStorage.car.inside["glove box"]; 20 | console.log(gloveBoxContents); 21 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/091_testing_objects_for_properties.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | // Sometimes it is useful to check if the property of a given object exists or not. We can use the .hasOwnProperty(propname) method of objects to determine if that object has the given property name. .hasOwnProperty() returns true or false if the property is found or not. 4 | 5 | // Task: Modify the function checkObj to test if an object passed to the function (obj) contains a specific property (checkProp). If the property is found, return that property's value. If not, return "Not Found". 6 | 7 | function checkObj(obj, checkProp) { 8 | if(obj.hasOwnProperty(checkProp)) { 9 | return obj[checkProp]; 10 | } else { 11 | return "Not Found"; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/007_uninitialized_variables.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | /* 4 | Understanding Uninitialized Variables 5 | 6 | When JavaScript variables are declared, they have an initial value of undefined. 7 | Mathematical operation on an undefined variable will be NaN which means "Not a Number". 8 | Concatenate a string with an undefined variable, you will get a literal string of undefined.*/ 9 | 10 | // Task: Initialize the three variables a, b, and c with 5, 10, and "I am a" respectively so that they will not be undefined. 11 | 12 | // Only change code below this line 13 | var a; 14 | var b; 15 | var c; 16 | 17 | // Only change code above this line 18 | a = 5; 19 | b = 10; 20 | c = "I am a"; 21 | 22 | a = a + 1; 23 | b = b + 5; 24 | c = c + " String!"; 25 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/061_comparison_with_the_strict_equality_operator.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | /* 4 | Strict equality (===) is the counterpart to the equality operator (==). 5 | However, unlike the equality operator, which attempts to convert both values being compared to a common type, 6 | the strict equality operator does not perform a type conversion.*/ 7 | 8 | // Task: Use the strict equality operator in the if statement so the function will return the string Equal when val is strictly equal to 7. 9 | 10 | // Setup 11 | function testStrict(val) { 12 | if (val === 7) { 13 | return "Equal"; 14 | } 15 | return "Not Equal"; 16 | } 17 | 18 | console.log(testStrict(10)); 19 | console.log(testStrict("7")); 20 | console.log(testStrict(7)); 21 | 22 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/053_local_scope_and_functions.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | // Variables which are declared within a function, as well as the function parameters, have local scope. That means they are only visible within that function. 4 | 5 | /* 6 | Task: The editor has two console.logs to help you see what is happening. 7 | Check the console as you code to see how it changes. Declare a local variable myVar inside myLocalScope and run the tests. 8 | */ 9 | 10 | function myLocalScope() { 11 | // Only change code below this line 12 | const myVar = 5; 13 | console.log('inside myLocalScope', myVar); 14 | } 15 | myLocalScope(); 16 | // Run and check the console 17 | // myVar is not defined outside of myLocalScope 18 | console.log('outside myLocalScope', myVar); 19 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/004_assigning_the_value_of_one_variable_to_another.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | /* 4 | After a value is assigned to a variable using the assignment operator, you can assign the value of that variable to another variable using the assignment operator. 5 | 6 | var myVar; 7 | myVar = 5; 8 | var myNum; 9 | myNum = myVar; 10 | 11 | The above declares a myVar variable with no value, then assigns it the value 5. 12 | Next, a variable named myNum is declared with no value. 13 | Then, the contents of myVar (which is 5) is assigned to the variable myNum. 14 | Now, myNum also has the value of 5. 15 | */ 16 | 17 | // Task: Assign the contents of a to variable b. 18 | // Setup 19 | var a; 20 | a = 7; 21 | var b; 22 | 23 | // Only change code below this line 24 | b = a; 25 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/074_chaining_if_else_statements.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | // if/else statements can be chained together for complex logic 4 | 5 | /* 6 | Task: Write chained if/else if statements to fulfill the following conditions: 7 | 8 | num < 5 - return Tiny 9 | num < 10 - return Small 10 | num < 15 - return Medium 11 | num < 20 - return Large 12 | num >= 20 - return Huge*/ 13 | 14 | function testSize(num) { 15 | if(num < 5) { 16 | return "Tiny" 17 | } else if (num < 10) { 18 | return "Small" 19 | } else if (num < 15) { 20 | return "Medium" 21 | } else if (num < 20) { 22 | return "Large" 23 | } else if (num >= 20) { 24 | return "Huge" 25 | } else { 26 | return "Change Me"; 27 | } 28 | } 29 | 30 | testSize(7); 31 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/029_concatenating_strings_with_the_plus_equals_operator.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | // We can also use the += operator to concatenate a string onto the end of an existing string variable. 3 | // This can be very helpful to break a long string over several lines. 4 | 5 | /* 6 | Task: Build myStr over several lines by concatenating these two strings: This is the first sentence. and 7 | This is the second sentence. using the += operator. Use the += operator similar to how it is shown in the 8 | example and be sure to include a space between the two strings. Start by assigning the first string to myStr, then add on the second string. 9 | */ 10 | 11 | let myStr; 12 | let myStr = "This is the first sentence."; 13 | myStr += " This is the second sentence."; 14 | 15 | console.log("My string", myStr) 16 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/026_quoting_strings_with_single_quotes.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | // String values in JavaScript may be written with single or double quotes, as long as you start and end with the same type of quote. 4 | // Unlike some other programming languages, single and double quotes work the same in JavaScript. 5 | 6 | /* 7 | Task: Change the provided string to a string with single quotes at the beginning and end and no escape characters. 8 | Right now, the tag in the string uses double quotes everywhere. 9 | You will need to change the outer quotes to single quotes so you can remove the escape characters. 10 | 11 | const myStr = "Link";*/ 12 | 13 | const myStr = 'Link'; 14 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/066_comparison_with_the_grater_than_or_equal_to_operator.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /* 3 | The greater than or equal to operator (>=) compares the values of two numbers. 4 | If the number to the left is greater than or equal to the number to the right, it returns true. Otherwise, it returns false. 5 | Like the equality operator, the greater than or equal to operator will convert data types while comparing.*/ 6 | 7 | // Task: Add the greater than or equal to operator to the indicated lines so that the return statements make sense. 8 | 9 | function testGreaterOrEqual(val) { 10 | if (val >= 20) { 11 | return "20 or Over"; 12 | } 13 | 14 | if (val >= 10) { 15 | return "10 or Over"; 16 | } 17 | 18 | return "Less than 10"; 19 | } 20 | 21 | testGreaterOrEqual(10); 22 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/085_accessing_object_properties_with_bracket_notation.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | // The second way to access the properties of an object is bracket notation ([]). If the property of the object you are trying to access has a space in its name, you will need to use bracket notation. 4 | 5 | // Task: Read the values of the properties an entree and the drink of testObj using bracket notation and assign them to entreeValue and drinkValue respectively. 6 | 7 | // Setup 8 | const testObj = { 9 | "an entree": "hamburger", 10 | "my side": "veggies", 11 | "the drink": "water" 12 | }; 13 | 14 | const entreeValue = testObj["an entree"]; 15 | const drinkValue = testObj["the drink"]; 16 | 17 | console.log("Entree value is: ", entreeValue); 18 | console.log("Drink value is: ", drinkValue); 19 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/068_comparison_with_the_less_than_or_equal_to_operator.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | /* 4 | The less than or equal to operator (<=) compares the values of two numbers. 5 | If the number to the left is less than or equal to the number to the right, it returns true. 6 | If the number on the left is greater than the number on the right, it returns false. 7 | Like the equality operator, the less than or equal to operator converts data types.*/ 8 | 9 | // Task: Add the less than or equal to operator to the indicated lines so that the return statements make sense. 10 | 11 | function testLessOrEqual(val) { 12 | if (val <= 12) { 13 | return "Smaller Than or Equal to 12"; 14 | } 15 | if (val <= 24) { 16 | return "Smaller Than or Equal to 24"; 17 | } 18 | return "More Than 24"; 19 | } 20 | 21 | testLessOrEqual(10); 22 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/038_word_blanks.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | /*Task: In this challenge, we provide you with a noun, a verb, an adjective and an adverb. You need to form a complete sentence using words of your choice, along with the words we provide. 4 | You will need to use the string concatenation operator + to build a new string, using the provided variables: myNoun, myAdjective, myVerb, and myAdverb. You will then assign the formed string to the wordBlanks variable. You should not change the words assigned to the variables. 5 | You will also need to account for spaces in your string, so that the final sentence has spaces between all the words. The result should be a complete sentence.*/ 6 | 7 | const myNoun = "dog"; 8 | const myAdjective = "big"; 9 | const myVerb = "ran"; 10 | const myAdverb = "quickly"; 11 | 12 | const wordBlanks = "The " + myNoun + " " + myAdjective + " " + myVerb + " " + myAdverb; 13 | -------------------------------------------------------------------------------- /02_ES6/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | ES6 8 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/010_read_only_variable_const_keyword.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | // In 02_ES6, you can also declare variables using the const keyword. 4 | // Declared using const are read-only. They are a constant value, which means that once a variable is assigned with const, it cannot be reassigned: 5 | /* 6 | Task: Change the code so that all variables are declared using let or const. 7 | Use let when you want the variable to change, and const when you want the variable to remain constant. 8 | Also, rename variables declared with const to conform to common practices, meaning constants should be in all caps.*/ 9 | 10 | /* 11 | var fCC = "freeCodeCamp"; // Change this line 12 | var fact = "is cool!"; // Change this line 13 | fact = "is awesome!"; 14 | console.log(fCC, fact); // Change this line*/ 15 | 16 | const FCC = "freeCodeCamp"; 17 | let fact = "is cool!"; 18 | fact = "is awesome!"; 19 | console.log(FCC, fact); 20 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/113_use_recursion_to_create_a_range_numbers.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | // Task :We have defined a function named rangeOfNumbers with two parameters. The function should return an array of integers which begins with a number represented by the startNum parameter and ends with a number represented by the endNum parameter. The starting number will always be less than or equal to the ending number. Your function must use recursion by calling itself and not use loops of any kind. It should also work for cases where both startNum and endNum are the same. 4 | 5 | let data = [] 6 | function rangeOfNumbers(startNum, endNum) { 7 | if (startNum > endNum) { 8 | return data; 9 | } else if (startNum === endNum) { 10 | data.push(endNum) 11 | return data; 12 | } else { 13 | data.push(startNum); 14 | rangeOfNumbers(startNum + 1, endNum); 15 | return data; 16 | } 17 | }; 18 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/001_comment_your_javascript_code.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | /* 4 | Comments are lines of code that JavaScript will intentionally ignore. 5 | Comments are a great way to leave notes to yourself and to other people who will later need to figure out what that code does.*/ 6 | 7 | // There are two ways to write comments in JavaScript: 8 | 9 | // Using // will tell JavaScript to ignore the remainder of the text on the current line. This is an in-line comment: 10 | // This is an in-line comment. 11 | 12 | 13 | // You can make a multi-line comment beginning with /* and ending with */. This is a multi-line comment: 14 | /* This is a 15 | multi-line comment */ 16 | 17 | // Tasks 18 | 19 | // 1- You should create a // style comment that contains at least five letters. 20 | 21 | // Fist inline comment 22 | 23 | // 2- You should create a /* */ style comment that contains at least five letters. 24 | 25 | /* This is a 26 | multi-line comment */ 27 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/057_stand_in_line.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | /* 4 | Challenge 5 | 6 | In Computer Science a queue is an abstract Data Structure where items are kept in order. New items can be added at the back of the queue and old items are taken off from the front of the queue. 7 | Write a function nextInLine which takes an array (arr) and a number (item) as arguments. 8 | Add the number to the end of the array, then remove the first element of the array. 9 | The nextInLine function should then return the element that was removed.*/ 10 | 11 | function nextInLine(arr, item) { 12 | // Add number to the end of array 13 | arr.push(item); 14 | // Remove the first element of the array 15 | return arr.shift(); 16 | } 17 | 18 | // Setup 19 | const testArr = [1, 2, 3, 4, 5]; 20 | 21 | // Display code 22 | console.log("Before: " + JSON.stringify(testArr)); 23 | console.log(nextInLine(testArr, 6)); 24 | console.log("After: " + JSON.stringify(testArr)); 25 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/027_escape_sequences_in_strings.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | // Quotes are not the only characters that can be escaped inside a string. There are two reasons to use escaping characters: 4 | // 5 | // 1) To allow you to use characters you may not otherwise be able to type out, such as a carriage return. 6 | // 2) To allow you to represent multiple quotes in a string without JavaScript misinterpreting what you mean. 7 | 8 | /* 9 | 10 | Task: Assign the following three lines of text into the single variable myStr using escape sequences. 11 | 12 | FirstLine 13 | \SecondLine 14 | ThirdLine 15 | 16 | You will need to use escape sequences to insert special characters correctly. You will also need to follow the spacing as it looks above, with no spaces between escape sequences or words. 17 | Note: The indentation for SecondLine is achieved with the tab escape character, not spaces.*/ 18 | 19 | const myStr = "FirstLine\n\t\\SecondLine\nThirdLine"; 20 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/059_use_conditional_logic_with_if_statement.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | /* 4 | if statements are used to make decisions in code. The keyword if tells JavaScript to execute the code in the curly braces under certain conditions, defined in the parentheses. 5 | These conditions are known as Boolean conditions and they may only be true or false. 6 | When the condition evaluates to true, the program executes the statement inside the curly braces. 7 | When the Boolean condition evaluates to false, the statement inside the curly braces will not execute.*/ 8 | 9 | 10 | // Task: Create an if statement inside the function to return Yes, that was true if the parameter wasThatTrue is true and return No, that was false otherwise. 11 | 12 | function trueOrFalse(wasThatTrue) { 13 | if (wasThatTrue) { 14 | return "Yes, that was true"; 15 | } else { 16 | return "No, that was false"; 17 | } 18 | } 19 | 20 | console.log(trueOrFalse(true)); 21 | console.log(trueOrFalse(false)); 22 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/077_adding_default_option_in_switch_statement.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | /* 4 | In a switch statement you may not be able to specify all possible values as case statements. 5 | Instead, you can add the default statement which will be executed if no matching case statements are found. Think of it like the final else statement in an if/else chain. 6 | A default statement should be the last case.*/ 7 | 8 | /* 9 | Task: Write a switch statement to set answer for the following conditions: 10 | a - apple 11 | b - bird 12 | c - cat 13 | default - stuff*/ 14 | 15 | 16 | function switchOfStuff(val) { 17 | let answer = ""; 18 | switch (val) { 19 | case "a": 20 | answer = "apple"; 21 | break; 22 | case "b": 23 | answer = "bird"; 24 | break; 25 | case "c": 26 | answer = "cat"; 27 | break; 28 | default: 29 | answer = "stuff"; 30 | break; 31 | } 32 | return answer; 33 | } 34 | 35 | switchOfStuff(1); 36 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/076_selecting_from_many_options_with_switch_statements.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | /* 4 | If you have many options to choose from, use a switch statement. 5 | A switch statement tests a value and can have many case statements which define various possible values. 6 | Statements are executed from the first matched case value until a break is encountered. 7 | */ 8 | 9 | /*Write a switch statement which tests val and sets answer for the following conditions: 10 | 1 - alpha 11 | 2 - beta 12 | 3 - gamma 13 | 4 - delta*/ 14 | 15 | 16 | function caseInSwitch(val) { 17 | let answer = ""; 18 | switch(val) { 19 | case 1: 20 | answer = "alpha"; 21 | break; 22 | case 2: 23 | answer = "beta"; 24 | break; 25 | case 3: 26 | answer = "gamma"; 27 | break; 28 | case 4: 29 | answer = "delta"; 30 | break; 31 | } 32 | return answer; 33 | } 34 | 35 | caseInSwitch(1); 36 | -------------------------------------------------------------------------------- /02_ES6/01_compare_scopes_of_the_var_and_let_keywords.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | // When you declare a variable with the var keyword, it is declared globally, or locally if declared inside a function. 4 | //The let keyword behaves similarly, but with some extra features. When you declare a variable with the let keyword inside a block, statement, or expression, its scope is limited to that block, statement, or expression. 5 | 6 | /* 7 | Task: Fix the code so that i declared in the if statement is a separate variable than i declared in the first line of the function. Be certain not to use the var keyword anywhere in your code. 8 | This exercise is designed to illustrate the difference between how var and let keywords assign scope to the declared variable. When programming a function similar to the one used in this exercise, it is often better to use different variable names to avoid confusion. 9 | 10 | */ 11 | 12 | 13 | function checkScope() { 14 | let i = 'function scope'; 15 | if (true) { 16 | let i = 'block scope'; 17 | console.log('Block scope i is: ', i); 18 | } 19 | console.log('Function scope i is: ', i); 20 | return i; 21 | } 22 | checkScope(); 23 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/078_multiple_identical_options_in_switch_statements.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | /* 4 | If the break statement is omitted from a switch statement's case, the following case statement(s) are executed until a break is encountered. If you have multiple inputs with the same output, you can represent them in a switch statement like this: 5 | 6 | let result = ""; 7 | switch(val) { 8 | case 1: 9 | case 2: 10 | case 3: 11 | result = "1, 2, or 3"; 12 | break; 13 | case 4: 14 | result = "4 alone"; 15 | } 16 | Cases for 1, 2, and 3 will all produce the same result.*/ 17 | 18 | /* 19 | Task: Write a switch statement to set answer for the following ranges: 20 | 1-3 - Low 21 | 4-6 - Mid 22 | 7-9 - High 23 | */ 24 | 25 | function sequentialSizes(val) { 26 | let answer = ""; 27 | switch (val) { 28 | case 1: 29 | case 2: 30 | case 3: 31 | answer = "Low"; 32 | break; 33 | case 4: 34 | case 5: 35 | case 6: 36 | answer = "Mid"; 37 | break; 38 | case 7: 39 | case 8: 40 | case 9: 41 | answer = "High" 42 | break; 43 | } 44 | return answer; 45 | } 46 | 47 | sequentialSizes(1); 48 | 49 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/052_global_scope_and_functions.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | // In JavaScript, scope refers to the visibility of variables. Variables which are defined outside of a function block have Global scope. 4 | // This means, they can be seen everywhere in your JavaScript code. 5 | // Variables which are declared without the let or const keywords are automatically created in the global scope. This can create unintended consequences elsewhere in your code or when running a function again. 6 | // You should always declare your variables with let or const. 7 | 8 | /* 9 | Task: Using let or const, declare a global variable named myGlobal outside of any function. Initialize it with a value of 10. 10 | Inside function fun1, assign 5 to oopsGlobal without using the let or const keywords. 11 | */ 12 | 13 | // Declare the myGlobal variable 14 | const myGlobal = 10; 15 | 16 | function fun1() { 17 | // Assign 5 to oopsGlobal 18 | oopsGlobal = 5; 19 | } 20 | 21 | // Only change code above this line 22 | 23 | function fun2() { 24 | var output = ""; 25 | if (typeof myGlobal != "undefined") { 26 | output += "myGlobal: " + myGlobal; 27 | } 28 | if (typeof oopsGlobal != "undefined") { 29 | output += " oopsGlobal: " + oopsGlobal; 30 | } 31 | console.log(output); 32 | } 33 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/112_use _recursion_to_create_a_countdown.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | /* 4 | In a previous challenge, you learned how to use recursion to replace a for loop. Now, let's look at a more complex function that returns an array of consecutive integers starting with 1 through the number passed to the function. 5 | 6 | As mentioned in the previous challenge, there will be a base case. The base case tells the recursive function when it no longer needs to call itself. It is a simple case where the return value is already known. There will also be a recursive call which executes the original function with different arguments. If the function is written correctly, eventually the base case will be reached. 7 | 8 | For example, say you want to write a recursive function that returns an array containing the numbers 1 through n. This function will need to accept an argument, n, representing the final number. Then it will need to call itself with progressively smaller values of n until it reaches 1.*/ 9 | 10 | 11 | // Only change code below this line 12 | let countArray = []; 13 | function countdown(n) { 14 | if(n < 1) { 15 | return countArray; 16 | } else { 17 | countArray.push(n); 18 | countdown(n - 1); 19 | return countArray; 20 | } 21 | } 22 | 23 | console.log(countdown(6)); 24 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/079_replacing_if_else_chains_with_switch.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | // If you have many options to choose from, a switch statement can be easier to write than many chained if/else if statements 4 | 5 | /* 6 | Task: Change the chained if/else if statements into a switch statement. 7 | 8 | function chainToSwitch(val) { 9 | let answer = ""; 10 | // Only change code below this line 11 | 12 | if (val === "bob") { 13 | answer = "Marley"; 14 | } else if (val === 42) { 15 | answer = "The Answer"; 16 | } else if (val === 1) { 17 | answer = "There is no #1"; 18 | } else if (val === 99) { 19 | answer = "Missed me by this much!"; 20 | } else if (val === 7) { 21 | answer = "Ate Nine"; 22 | } 23 | 24 | // Only change code above this line 25 | return answer; 26 | } 27 | 28 | chainToSwitch(7);*/ 29 | 30 | 31 | function chainToSwitch(val) { 32 | let answer = ""; 33 | switch(val) { 34 | case "bob": 35 | answer = "Marley"; 36 | break; 37 | case 42: 38 | answer = "The Answer"; 39 | break; 40 | case 1: 41 | answer = "There is no #1"; 42 | break; 43 | case 99: 44 | answer = "Missed me by this much!"; 45 | break; 46 | case 7: 47 | answer = "Ate Nine"; 48 | break; 49 | } 50 | return answer; 51 | } 52 | 53 | chainToSwitch(7); 54 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/075_golf_code.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | /* 4 | In the game of golf, each hole has a par, meaning, the average number of strokes a golfer is expected to make in order to sink the ball in the hole to complete the play. 5 | Depending on how far above or below par your strokes are, there is a different nickname. 6 | Your function will be passed par and strokes arguments. Return the correct string according to this table which lists the strokes in order of priority; top (highest) to bottom (lowest): 7 | 8 | Strokes Return 9 | 1 "Hole-in-one!" 10 | <= par - 2 "Eagle" 11 | par - 1 "Birdie" 12 | par "Par" 13 | par + 1 "Bogey" 14 | par + 2 "Double Bogey" 15 | >= par + 3 "Go Home!" 16 | par and strokes will always be numeric and positive. 17 | We have added an array of all the names for your convenience.*/ 18 | 19 | 20 | const names = ["Hole-in-one!", "Eagle", "Birdie", "Par", "Bogey", "Double Bogey", "Go Home!"]; 21 | 22 | function golfScore(par, strokes) { 23 | if(strokes === 1) { 24 | return "Hole-in-one!" 25 | } else if (strokes <= par - 2) { 26 | return "Eagle"; 27 | } else if (strokes === par - 1) { 28 | return "Birdie"; 29 | } else if (strokes === par) { 30 | return "Par"; 31 | } else if (strokes === par + 1) { 32 | return "Bogey"; 33 | } else if (strokes === par + 2) { 34 | return "Double Bogey"; 35 | } else if (strokes >= par + 3) { 36 | return "Go Home!"; 37 | } else { 38 | return "Change Me"; 39 | } 40 | } 41 | 42 | golfScore(5, 4); 43 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ### JavaScript Algorithms and Data Structures Certification :heavy_check_mark: 2 | * [x] [Basic JavaScript](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript) 3 | * [ ] [ES6](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structure/tree/master/ES6) 4 | * [ ] [Regular Expressions](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structure/tree/master/Regular%20Expressions) 5 | * [ ] [Debugging](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structure/tree/master/Debugging) 6 | * [ ] [Basic Data Structures](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structure/tree/master/Basic%20Data%20Structures) 7 | * [ ] [Algorithm Scripting](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structure/tree/master/Basic%20Algorithm%20Scripting) 8 | * [ ] [Object Oriented Programming](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structure/tree/master/Object%20Oriented%20Programming) 9 | * [ ] [Functional Programming](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structure/tree/master/Functional%20Programming) 10 | * [ ] [Intermediate Algorithm Scripting](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structure/tree/master/Intermediate%20Algorithm%20Scripting) 11 | * [ ] [JavaScript Algorithms and Data Structures Projects](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structure/tree/master/JavaScript%20Algorithms%20and%20Data%20Structures%20Projects) 12 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/090_using_objects_for_lookups.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | /* 4 | Objects can be thought of as a key/value storage, like a dictionary. If you have tabular data, you can use an object to lookup values rather than a switch statement or an if/else chain. 5 | This is most useful when you know that your input data is limited to a certain range.*/ 6 | 7 | /* 8 | Task: Convert the switch statement into an object called lookup. Use it to look up val and assign the associated string to the result variable. 9 | 10 | // Setup 11 | function phoneticLookup(val) { 12 | let result = ""; 13 | 14 | // Only change code below this line 15 | switch(val) { 16 | case "alpha": 17 | result = "Adams"; 18 | break; 19 | case "bravo": 20 | result = "Boston"; 21 | break; 22 | case "charlie": 23 | result = "Chicago"; 24 | break; 25 | case "delta": 26 | result = "Denver"; 27 | break; 28 | case "echo": 29 | result = "Easy"; 30 | break; 31 | case "foxtrot": 32 | result = "Frank"; 33 | } 34 | 35 | // Only change code above this line 36 | return result; 37 | } 38 | 39 | phoneticLookup("charlie");*/ 40 | 41 | 42 | // Setup 43 | function phoneticLookup(val) { 44 | let result = ""; 45 | const lookup = { 46 | "alpha": "Adams", 47 | "bravo": "Boston", 48 | "charlie": "Chicago", 49 | "delta": "Denver", 50 | "echo": "Easy", 51 | "foxtrot": "Frank", 52 | } 53 | result = lookup[val]; 54 | return result; 55 | } 56 | 57 | phoneticLookup("charlie"); 58 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/082_counting_cards.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | /*In the casino game Blackjack, a player can gain an advantage over the house by keeping track of the relative number of high and low cards remaining in the deck. 4 | This is called Card Counting. 5 | Having more high cards remaining in the deck favors the player. 6 | Each card is assigned a value according to the table below. 7 | When the count is positive, the player should bet high. 8 | When the count is zero or negative, the player should bet low.*/ 9 | 10 | /* 11 | Count Change Cards 12 | +1 2, 3, 4, 5, 6 13 | 0 7, 8, 9 14 | -1 10, 'J', 'Q', 'K', 'A' 15 | */ 16 | 17 | /* 18 | Task: You will write a card counting function. 19 | It will receive a card parameter, which can be a number or a string, and increment or decrement the global count variable according to the card's value (see table).' + 20 | 'The function will then return a string with the current count and the string Bet if the count is positive, or Hold if the count is zero or negative. The current count and the player's decision (Bet or Hold) should be separated by a single space. 21 | Example Outputs: -3 Hold or 5 Bet 22 | */ 23 | 24 | let count = 0; 25 | 26 | function cc(card) { 27 | switch(card) { 28 | case 2: 29 | case 3: 30 | case 4: 31 | case 5: 32 | case 6: 33 | count += 1; 34 | break; 35 | case 7: 36 | case 8: 37 | case 9: 38 | count += 0; 39 | break; 40 | case 10: 41 | case 'J': 42 | case 'Q': 43 | case 'K': 44 | case 'A': 45 | count -= 1; 46 | break; 47 | } 48 | if(count > 0) { 49 | return count + " Bet" 50 | } else { 51 | return count + " Hold" 52 | } 53 | } 54 | 55 | cc(2); cc(3); cc(7); cc('K'); cc('A'); 56 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/104_profile_lookup.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | /* 4 | Task: We have an array of objects representing different people in our contacts lists. 5 | A lookUpProfile function that takes name and a property (prop) as arguments has been pre-written for you. 6 | The function should check if name is an actual contact's firstName and the given property (prop) is a property of that contact. 7 | If both are true, then return the "value" of that property. 8 | If name does not correspond to any contacts then return the string No such contact. 9 | If prop does not correspond to any valid properties of a contact found to match name then return the string No such property.*/ 10 | 11 | 12 | // Setup 13 | const contacts = [ 14 | { 15 | firstName: "Akira", 16 | lastName: "Laine", 17 | number: "0543236543", 18 | likes: ["Pizza", "Coding", "Brownie Points"], 19 | }, 20 | { 21 | firstName: "Harry", 22 | lastName: "Potter", 23 | number: "0994372684", 24 | likes: ["Hogwarts", "Magic", "Hagrid"], 25 | }, 26 | { 27 | firstName: "Sherlock", 28 | lastName: "Holmes", 29 | number: "0487345643", 30 | likes: ["Intriguing Cases", "Violin"], 31 | }, 32 | { 33 | firstName: "Kristian", 34 | lastName: "Vos", 35 | number: "unknown", 36 | likes: ["JavaScript", "Gaming", "Foxes"], 37 | }, 38 | ]; 39 | 40 | function lookUpProfile(name, prop) { 41 | for (let i = 0; i < contacts.length; i++) { 42 | if (contacts[i].firstName === name) { 43 | if (contacts[i].hasOwnProperty(prop)) { 44 | return contacts[i][prop]; 45 | } else { 46 | return "No such property"; 47 | } 48 | } 49 | } 50 | return "No such contact"; 51 | } 52 | 53 | lookUpProfile("Akira", "likes"); 54 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/095_record_collection.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | /* 4 | Task: You are given an object literal representing a part of your musical album collection. Each album has a unique id number as its key and several other properties. Not all albums have complete information. 5 | You start with an updateRecords function that takes an object literal, records, containing the musical album collection, an id, a prop (like artist or tracks), and a value. Complete the function using the rules below to modify the object passed to the function. 6 | Your function must always return the entire record collection object. 7 | If prop isn't tracks and value isn't an empty string, update or set that album's prop to value. 8 | If prop is tracks but the album doesn't have a tracks property, create an empty array and add value to it. 9 | If prop is tracks and value isn't an empty string, add value to the end of the album's existing tracks array. 10 | If value is an empty string, delete the given prop property from the album.*/ 11 | 12 | // Setup 13 | const recordCollection = { 14 | 2548: { 15 | albumTitle: 'Slippery When Wet', 16 | artist: 'Bon Jovi', 17 | tracks: ['Let It Rock', 'You Give Love a Bad Name'] 18 | }, 19 | 2468: { 20 | albumTitle: '1999', 21 | artist: 'Prince', 22 | tracks: ['1999', 'Little Red Corvette'] 23 | }, 24 | 1245: { 25 | artist: 'Robert Palmer', 26 | tracks: [] 27 | }, 28 | 5439: { 29 | albumTitle: 'ABBA Gold' 30 | } 31 | }; 32 | 33 | // Only change code below this line 34 | function updateRecords(records, id, prop, value) { 35 | if(prop !== "tracks" && value !== "") { 36 | records[id][prop] = value; 37 | } else if (prop === "tracks" && !(records[id].hasOwnProperty("tracks"))) { 38 | records[id][prop] = []; 39 | records[id][prop].push(value); 40 | } else if (prop === "tracks" && value !== "") { 41 | records[id][prop].push(value); 42 | } else if(value === "") { 43 | delete records[id][prop]; 44 | } 45 | return records; 46 | } 47 | 48 | updateRecords(recordCollection, 5439, 'artist', 'ABBA'); 49 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Basic Javascript 8 | 26 | 27 | 28 |

Basic Javascript

29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 |

144 | 145 | 146 | -------------------------------------------------------------------------------- /01_Basic_JavaScript/README.md: -------------------------------------------------------------------------------- 1 | ### Basic JavaScript :heavy_check_mark: 2 | * [x] [001 Comment Your JavaScript Code](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/001_comment_your_javascript_code.js) 3 | * [x] [002 Declare JavaScript Variables](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/002_declare_javascript_variables.js) 4 | * [x] [003 Storing Values with the Assignment Operator](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/003_storing_values_with_assignment_operator.js) 5 | * [x] [004 Assigning the value of One Variable to Another](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/004_assigning_the_value_of_one_variable_to_another.js) 6 | * [x] [005 Initializing Variables with the Assignment Operator](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/005_initializing_variables_with_assignment_operator.js) 7 | * [x] [006 Declare String Variables](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/006_declare_string_variables.js) 8 | * [x] [007 Understanding Uninitialized Variables](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/007_uninitialized_variables.js) 9 | * [x] [008 Understanding Case Sensitivity in Variables](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/008_case_sensitivity_in_variables.js) 10 | * [x] [009 Differences Between the var and let Keywords](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/009_let_var_keywords.js) 11 | * [x] [010 Declare a Read-Only Variable with the const Keyword](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/010_read_only_variable_const_keyword.js) 12 | * [x] [011 Add Two Numbers with JavaScript](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/011_add_two_numbers_with_javaScript.js) 13 | * [x] [012 Subtract One Number from Another with JavaScript](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/012_substract_one_number_from_another_with_javaScript.js) 14 | * [x] [013 Multiply Two Numbers with JavaScript](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/013_multiply_two_numbers_with_javaScript.js) 15 | * [x] [014 Divide One Number by Another with JavaScript](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/014_divide_one_number_by_another_with_javascript.js) 16 | * [x] [015 Increment a Number with JavaScript](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/015_increment_a_number_with_javaScript.js) 17 | * [x] [016 Decrement a Number with JavaScript](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/016_decrement_a_number_with_javaScript.js) 18 | * [x] [017 Create Decimal Numbers with JavaScript](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/017_create_decimal_number_with_javaScript.js) 19 | * [x] [018 Multiply Two Decimals with JavaScript](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/018_multiply_two_decimals_with_javaScript.js) 20 | * [x] [019 Divide One Decimal by Another with JavaScript](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/019_divide_one_decimal_by_another_with_javaScript.js) 21 | * [x] [020 Finding a Remainder in JavaScript](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/020_finding_a_remainder_in_javaScript.js) 22 | * [x] [021 Compound Assignment With Augmented Addition](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/021_compound_assignment_with_augmented_addition.js) 23 | * [x] [022 Compound Assignment With Augmented Subtraction](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/022_compound_assignment_with_augmented_subtraction.js) 24 | * [x] [023 Compound Assignment With Augmented Multiplication](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/023_compound_assignment_with_augmented_multiplication.js) 25 | * [x] [024 Compound Assignment With Augmented Division](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/024_compound_assignment_with_augmented_division.js) 26 | * [x] [025 Escaping Literal Quotes in Strings](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/025_escaping_literal_quotes_in_strings.js) 27 | * [x] [026 Quoting Strings with Single Quotes](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/026_quoting_strings_with_single_quotes.js) 28 | * [x] [027 Escape Sequences in Strings](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/027_escape_sequences_in_strings.js) 29 | * [x] [028 Concatenating Strings with Plus Operator](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/028_concatenating_strings_with_plus_operator.js) 30 | * [x] [029 Concatenating Strings with the Plus Equals Operator](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/029_concatenating_strings_with_the_plus_equals_operator.js) 31 | * [x] [030 Constructing Strings with Variables](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/030_constructing_strings_with_variables.js) 32 | * [x] [031 Appending Variables to Strings](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/031_appending_variables_to_string.js) 33 | * [x] [032 Find the Length of a String](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/032_find_length_of_a_string.js) 34 | * [x] [033 Use Bracket Notation to Find the First Character in a String](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/033_use_brack_notation_to_find_the_first_character_in_a_string.js) 35 | * [x] [034 Understand String Immutability](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/034_understanding_string_immutability.js) 36 | * [x] [035 Use Bracket Notation to Find the Nth Character in a String](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/035_use_bracket_notation_to_find_the_nth_character_in_a_string.js) 37 | * [x] [036 Use Bracket Notation to Find the Last Character in a String](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/036_use_bracket_notation_to_find_the_last_character_in_a_string.js) 38 | * [x] [037 Use Bracket Notation to Find the Nth-to-Last Character in a String](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/037_use_bracket_notation_to_find_the_nth_to_last_character_in_a_string.js) 39 | * [x] [038 Word Blanks](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/038_word_blanks.js) 40 | * [x] [039 Store Multiple Values in one Variable using JavaScript Arrays](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/039_store_multiple_values_in_one_variable_using_javaScript_arrays.js) 41 | * [x] [040 Nest one Array within Another Array](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/040_nest_one_array_within_another.js) 42 | * [x] [041 Access Array Data with Indexes](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/041_access_array_data_with_indexes.js) 43 | * [x] [042 Modify Array Data With Indexes](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/042_modify_array_data_with_indexes.js) 44 | * [x] [043 Access Multi-Dimensional Arrays With Indexes](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/043_access_multi_dimensional_array_with_indexes.js) 45 | * [x] [044 Manipulate Arrays With push()](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/044_manipulate_arrays_with_push.js) 46 | * [x] [045 Manipulate Arrays With pop()](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/045_manipulate_array_with_pop.js) 47 | * [x] [046 Manipulate Arrays With shift()](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/046_manipulate_arrays_with_shift.js) 48 | * [x] [047 Manipulate Arrays With unshift()](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/047_manipulate_arrays_with_unshift.js) 49 | * [x] [048 Shopping List](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/048_shopping_list.js) 50 | * [x] [049 Write Reusable JavaScript with Functions](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/049_functions.js) 51 | * [x] [050 Passing Values to Functions with Arguments](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/050_passing_values_to_functions_with_arguments.js) 52 | * [x] [051 Return a Value from a Function with Return](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/051_return_a_value_from_a_function_with_return.js) 53 | * [x] [052 Global Scope and Functions](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/052_global_scope_and_functions.js) 54 | * [x] [053 Local Scope and Functions](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/053_local_scope_and_functions.js) 55 | * [x] [054 Global vs. Local Scope in Functions](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/054_local_global_scope_with_functions.js) 56 | * [x] [055 Understanding Undefined Value returned from a Function](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/055_understanding_undefined_value_returned_from_a_function.js) 57 | * [x] [056 Assignment with a Returned Value](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/056_assignment_with_a_returned_value.js) 58 | * [x] [057 Stand in Line](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/057_stand_in_line.js) 59 | * [x] [058 Understanding Boolean Values](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/058_understanding_boolean_values.js) 60 | * [x] [059 Use Conditional Logic with If Statements](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/059_use_conditional_logic_with_if_statement.js) 61 | * [x] [060 Comparison with the Equality Operator](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/060_comparison_with_the_equality_operator.js) 62 | * [x] [061 Comparison with the Strict Equality Operator](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/061_comparison_with_the_strict_equality_operator.js) 63 | * [x] [062 Practice comparing different values](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/062_practice_comparing_different_values.js) 64 | * [x] [063 Comparison with the Inequality Operator](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/063_comparison_with_the_inequality_operator.js) 65 | * [x] [064 Comparison with the Strict Inequality Operator](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/064_comparison_with_the_strict_inequality_operator.js) 66 | * [x] [065 Comparison with the Greater Than Operator](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/065_comparison_with_the_grater_than_operator.js) 67 | * [x] [066 Comparison with the Greater Than Or Equal To Operator](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/066_comparison_with_the_grater_than_or_equal_to_operator.js) 68 | * [x] [067 Comparison with the Less Than Operator](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/067_comparison_with_the_less_than_operator.js) 69 | * [x] [068 Comparison with the Less Than Or Equal To Operator](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/068_comparison_with_the_less_than_or_equal_to_operator.js) 70 | * [x] [069 Comparisons with the Logical And Operator](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/069_comparisons_with_the_logical_and_operator.js) 71 | * [x] [070 Comparisons with the Logical Or Operator](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/070_comparisons_with_the_logical_or_operator.js) 72 | * [x] [071 Introducing Else Statements](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/071_introducing_else_statement.js) 73 | * [x] [072 Introducing Else If Statements](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/072_introducing_else_if_statements.js) 74 | * [x] [073 Logical Order in If Else Statements](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/073_logical_order_in_if_else_statements.js) 75 | * [x] [074 Chaining If Else Statements](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/074_chaining_if_else_statements.js) 76 | * [x] [075 Golf Code](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/075_golf_code.js) 77 | * [x] [076 Selecting from Many Options with Switch Statements](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/076_selecting_from_many_options_with_switch_statements.js) 78 | * [x] [077 Adding a Default Option in Switch Statements](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/077_adding_default_option_in_switch_statement.js) 79 | * [x] [078 Multiple Identical Options in Switch Statements](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/078_multiple_identical_options_in_switch_statements.js) 80 | * [x] [079 Replacing If Else Chains with Switch](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/079_replacing_if_else_chains_with_switch.js) 81 | * [x] [080 Returning Boolean Values from Functions](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/080_returning_boolean_values_from_functions.js) 82 | * [x] [081 Return Early Pattern for Functions](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/081_return_early_pattern_for_functions.js) 83 | * [x] [082 Counting Cards](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/082_counting_cards.js) 84 | * [x] [083 Build JavaScript Objects](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/083_build_javaScript_objects.js) 85 | * [x] [084 Accessing Object Properties with Dot Notation](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/084_accessing_object_properties_with_dot_notation.js) 86 | * [x] [085 Accessing Object Properties with Bracket Notation](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/085_accessing_object_properties_with_bracket_notation.js) 87 | * [x] [086 Accessing Object Properties with Variables](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/086_accessing_object_properties_with_variables.js) 88 | * [x] [087 Updating Object Properties](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/087_updating_object_properties.js) 89 | * [x] [088 Add New Properties to a JavaScript Object](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/088_add_new_properties_to_javaScript_object.js) 90 | * [x] [089 Delete Properties from a JavaScript Object](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/089_delete_properties_from_a_javaScript_object.js) 91 | * [x] [090 Using Objects for Lookups](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/090_using_objects_for_lookups.js) 92 | * [x] [091 Testing Objects for Properties](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/091_testing_objects_for_properties.js) 93 | * [x] [092 Manipulating Complex Objects](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/092_manipulating_complex_objects.js) 94 | * [x] [093 Accessing Nested Objects](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/093_accessing_nested_objects.js) 95 | * [x] [094 Accessing Nested Arrays](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/094_accessing_nested_arrays.js) 96 | * [x] [095 Record Collection](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/095_record_collection.js) 97 | * [x] [096 Iterate with JavaScript While Loops](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/096_iterate_with_javaScript_while_loops.js) 98 | * [x] [097 Iterate with JavaScript For Loops](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/097_iterate_with_javaScript_for_loops.js) 99 | * [x] [098 Iterate Odd Numbers With a For Loop](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/098_iterate_odd_numbers_with_a_for_loop.js) 100 | * [x] [099 Count Backwards With a For Loop](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/099_count_backwards_with_a_for_loop.js) 101 | * [x] [100 Iterate Through an Array with a For Loop](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/100_iterate_through_an_array_with_a_for_loop.js) 102 | * [x] [101 Nesting For Loops](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/101_nesting_loops.js) 103 | * [x] [102 Iterate with JavaScript Do...While Loops](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/102_iterate_with_javaScript_do_while_loops.js) 104 | * [x] [103 Replace Loops using Recursion](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/103_replace_loops_using_recursion.js) 105 | * [x] [104 Profile Lookup](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/104_profile_lookup.js) 106 | * [x] [105 Generate Random Fractions with JavaScript](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/105_generate_random_functions_with_javaScript.js) 107 | * [x] [106 Generate Random Whole Numbers with JavaScript](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/106_generate_random_whole_numbers_with_javaScript.js) 108 | * [x] [107 Generate Random Whole Numbers within a Range](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/107_generate_random_whole_numbers_within_a_range.js) 109 | * [x] [108 Use the parseInt Function](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/108_use_the_parse_int_function.js) 110 | * [x] [109 Use the parseInt Function with a Radix](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/109_une_the_parseInt_function_with_a_radix.js) 111 | * [x] [110 Use the Conditional (Ternary) Operator](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/110_use_the_conditional_operator.js) 112 | * [x] [111 Use Multiple Conditional (Ternary) Operators](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/111_use_multiple_conditional_operators.js) 113 | * [x] [112 Use Recursion to Create a Countdown](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/112_use_recursion_to_create_a_countdown.js) 114 | * [x] [113 Use Recursion to Create a Range of Numbers](https://github.com/somekindofwallflower/javascript-algorithms-and-data-structures/tree/master/01_Basic_JavaScript/113_use_recursion_to_create_a_range_numbers.js) 115 | --------------------------------------------------------------------------------