165 it("should throw an error if 'email' is undefined", () => {
166 const name = 'Bob';
167 const id = 20;
168 let emailUndefined;169 const officeNumber = 1001;
170
171 const cb = () => new Manager(name, id, emailUndefined, officeNumber);
95
96 it("should throw an error if 'id' is undefined", () => {
97 const name = 'Bob';
98 let idUndefined; 99 const email = '[email protected]';
100 const officeNumber = 1001;
101
50 });
51
52 it("should throw an error if 'name' is undefined", () => {
53 let nameUndefined; 54 const id = 20;
55 const email = '[email protected]';
56 const officeNumber = 1001;
165 it("should throw an error if 'email' is undefined", () => {
166 const name = 'Daniel';
167 const id = 1;
168 let emailUndefined;169 const school = 'University of Arizona';
170
171 const cb = () => new Intern(name, id, emailUndefined, school);
95
96 it("should throw an error if 'id' is undefined", () => {
97 const name = 'Daniel';
98 let idUndefined; 99 const email = '[email protected]';
100 const school = 'University of Arizona';
101
In JavaScript, variables can be assigned during declaration, or at any point afterwards using an assignment statement. For example, in the following code, foo
is initialized during declaration, while bar
is initialized later.
var foo = 1;
var bar;
if (foo) {
bar = 1;
} else {
bar = 2;
}
function foo() {
var bar;
let baz;
}
function foo() {
var bar = 1;
let baz = 2;
const qux = 3;
}