reading-notes

Readings: Debugging

Reading

What Went Wrong? Troubleshooting JavaScript

Name some key differences between a Syntax Error and a Logic Error.

List a few types of errors that you have encountered in past lab assignments and explain how you were able to correct them.

How will this topic continue to influence your long term goals?

The JavaScript Debugger

How would you describe the JavaScript Debugger tool and how it works to someone just starting out in software development?

Define what a breakpoint is.

What is the call stack?

Debugging Code in Repl

‘use strict’;

// Welcome to my student generator app! There are currently 3 types of errors in this application, 1. TypeError, 2. SyntaxError, 3. ReferenceError. Use the errors in the console to pinpoint the specific line number where the issue occurs and fix each new error as they occur.

// TODO: Render our new student objects as a list in the console

var cache = [];

var students = ‘Robb,Chuck,Kendrah,Cesar,Zach,Rae,Jallow,Kevin,Micahel,Josh,Shane,JT’;

// constructor for each instance of a student object function Student(name) { this.studentName = name; this.emailAddress = null; this.registeredCourse = null; this.enrolled = false;

cache.push(this); }

function normalizeInput(str) { // simulate receiving CSV data from a file and normalize it for our constructor. expected output is an array of names that is ready to use later. var students = str.split(‘,’); for (var i = 0; i < students.length; i++) { students[i] = students[i].toLowerCase(); } return students; }

Student.prototype.validate = function() { return ${this.studentName} added to the cache; }

function studentGenerator(arr){ // given an array, populate our global cache with objects and store them in our global cache.

// check if array exists if(Array.isArray(arr)) { for(var i = 0; i < arr.length; i++){ var newStudent = new Student(arr[i]);
console.log(newStudent.validate());

}
return `Completed.  ${i} entries added to cache.`;   }   else {
return 'This function only accepts arrays.  please try again.'   } }

function initialize(input) { var studentList = normalizeInput(input);

return studentGenerator(studentList);
}

initialize(students);