Ways to debugƬInsert console.log() statements to test expected valuesƬUsing Chrome Javascript ConsoleƬOpen javascript consoleƬPut break pointsƬRun the code line by lineƬPrint variablesƬRun function
Test Code - Example Walkthrough
cs142-test-project2.jsvar cs142MakeMultiFilter; var Cs142TemplateProcessor; Ƭglobal scopeƬundefined if they are not defined anywhereƬif they are defined in the global scope by some other script, they will have those values.Ƭbe careful of case when declaring your functions
cs142-test-project2.js- Testing p1typeof cs142MakeMultiFilter!== 'function'Ƭtypeof to see what cs142MakeMultiFilter is Ƭ!== versus !=Ɣ!== without type conversion
cs142-test-project2.js- Testing p1console.error('cs142MakeMultiFilter does not return a function', filterFunc);ƬLog an error message
Cs142-test-project2.js- Testing p1ƬCheck 1: Make sure cs142MakeFilterFunction returns a function when given the correct parameters
Cs142-test-project2.js- Testing p1ƬCheck 2: If there is no filter function passed in, return the original array