Day 2 of 100 Days Of Code

Day 2: July 26, Thursday

Today’s Progress: I’ve gone through the remaining exercises on FreeCodeCamp Debugging Project.

Thoughts I’ve had a lot of experiance debugging so was able to get though all the excersizes a couple we pretty tricky.

//Debugging: Use Caution When Reinitializing Variables Inside a Loop
// original buggy code...

function zeroArray(m, n) {
  // Creates a 2-D array with m rows and n columns of zeroes
  let newArray = [];
  let row = [];
  for (let i = 0; i < m; i++) {
    // Adds the m-th row into newArray
    /**** //the offending code Loop****
    for (let j = 0; j < n; j++) {
      // Pushes n zeroes into the current row to create the columns
      row.push(0);
    }
    */
    // Pushes the current row, which now has n zeroes in it, to the array
    newArray.push(row);
  }
  for (let j = 0; j < n; j++) { //my solution move outside first loop
      // Pushes n zeroes into the current row to create the columns
      row.push(0);
    }
  return newArray;
}
let matrix = zeroArray(3, 2);
console.log(matrix);

Link(s) to work

  1. Introduction to the Debugging Challenges
    • PassedCatch Misspelled Variable and Function Names
    • PassedCatch Unclosed Parentheses, Brackets, Braces and Quotes
    • PassedCatch Mixed Usage of Single and Double Quotes
    • PassedCatch Use of Assignment Operator Instead of Equality Operator
    • PassedCatch Missing Open and Closing Parenthesis After a Function Call
    • PassedCatch Arguments Passed in the Wrong Order When Calling a Function
    • PassedCatch Off By One Errors When Using Indexing
    • PassedUse Caution When Reinitializing Variables Inside a Loop
    • PassedPrevent Infinite Loops with a Valid Terminal Condition Code Here
Written on July 26, 2018