Chuyển đến nội dung chính

freecodecamp: javascript debugging

freecodecamp: javascript debugging

I note that passed code to help coder find the solution

Use the JavaScript Console to Check the Value of a Variable
"console.log(a);"
Understanding the Differences between the freeCodeCamp and Browser Console
"console.log(outputTwo);
console.clear();
console.log(outputOne);
"
Use typeof to Check the Type of a Variable
"console.log(typeof(seven));
console.log(typeof(three));"

Catch Misspelled Variable and Function Names
"" //copy &past variable
Catch Unclosed Parentheses, Brackets, Braces and Quotes
"let myArray = [1, 2, 3];
let arraySum = myArray.reduce((previous, current) => previous + current);"

Catch Mixed Usage of Single and Double Quotes
"let innerHtml = "<p>Click here to <a href=\"#Home\">return home</a></p>";"

Catch Use of Assignment Operator Instead of Equality Operator
"if(x == y)"

Catch Missing Open and Closing Parenthesis After a Function Call
"let result = getNine();"

Catch Arguments Passed in the Wrong Order When Calling a Function
"let power = raiseToPower(base,exp);"

Catch Off By One Errors When Using Indexing
"for (let i = 0; i < len; i++)"

Use Caution When Reinitializing Variables Inside a Loop
"function zeroArray(m, n) {
// Creates a 2-D array with m rows and n columns of zeroes
let newArray = [];
const row = [];
for (let j = 0; j < n; j++) {
// Pushes n zeroes into the current row to create the columns
row.push(0);
}
for (let i = 0; i <m; i++) {
// Adds the m-th row into newArray
// Pushes the current row, which now has n zeroes in it, to the array
newArray.push(row);
}
return newArray;
}

let matrix = zeroArray(3, 2);
console.log(matrix);"

Prevent Infinite Loops with a Valid Terminal Condition
"for (let i = 1; i <= 4; i += 2)"



Nhận xét

Bài đăng phổ biến từ blog này

freecodecamp: React

freecodecamp: React step by step to practice Create a Simple JSX Element " const JSX = <h1>Hello JSX!</h1>; " Create a Complex JSX Element " const JSX=<div> <h1></h1> <p></p> <ul> <li></li> <li></li> <li></li> </ul> </div>; " Add Comments in JSX " const JSX = ( /* here in first time */ <div> <h1>This is a block of JSX</h1> <p>Here 's a subtitle</p> </div> ); " Render HTML Elements to the DOM " const JSX = ( <div id= 'challenge-node' > <h1>Hello World</h1> <p>Lets render this to the DOM</p> </div> ); // change code below this line ReactDOM.render(JSX,document.getElementById( 'challenge-node' )); " Define an HTML Class in JSX " cons...

freecodecamp: basic data structures

freecodecamp: basic data structures I note passed challenge code for help. Use an Array to Store a Collection of Data " let yourArray=[ 1 , true , "3" , 4 , 5 ]; // change this line "  Access an Array's Contents Using Bracket Notation " myArray[ 1 ]= "bb" ; " Add Items to an Array with push() and unshift() " arr.unshift( "I" , 2 , "three" ); arr.push( 7 , "VIII" , 9 ); "  Remove Items from an Array with pop() and shift() " let popped=arr.pop(); // change this line let shifted=arr.shift(); // change this line " Remove Items Using splice() " // change code below this line arr.splice( 2 , 2 ); // change code above this line " Add Items Using splice() " // change code below this line arr.splice( 0 , 2 , 'DarkSalmon' , 'BlanchedAlmond' ); // change code above this line " ...