Day 4 Now let's get the code to make this happen. Add this code to the end of your html project file - after the input two arrays section. //Constraint procedures //Constraint 1: Anna has classes from 11Am - 1:50pm delList = [] for (a=0;a= 11 && x <= 14){ delList.push(x) //Anna/splice(a,1) //deleteAnna[a] } } //(Delete ALL of Anna's unavailable hours) searchDelete(delList,Anna) //Constraint 2: Betty has clases noon to 3pm //then has dance practive until 4pm delList = [] for (b=0;b= 12 && x < 16){ delList.push(x) } } //Delete ALL of Betty's unavailable hours) searchDelete(delList,Betty) //Constraint 3: Cara ha to work 7pm to 11pm delList = [] for (c=0;c=19 && x <= 23){ delList.push(x) } } //(Delete ALL of Cara's unavailable hours) searchDelete(delList,Cara) //Constraint 4: Donna has volunteeer hours from 6pm to 8pm delList = [] for (d=0;d=18 && x<=20){ delList.push(x) } } //Delete All of Donna's unavailable hours searchDelete(delList,Donna) //Constraint 5: Jerry has classes from 11Am - 1:50pm delList = [] for (e=0;e= 11 && x < 14){ delList.push(x) //Jerry/splice(a,1) //deleteJerry[e] } } //(Delete ALL ofJerry's unavailable hours) searchDelete(delList,Jerry) //Constraint 6: Ashley has classes from 1:00pm - 3:00pm delList = [] for (f=0;f= 13 && x < 15){ delList.push(x) //Ashley/splice(f,1) //deleteAshley[f] } } //(Delete ALL of Ashley's unavailable hours) searchDelete(delList,Ashley) console.log("Hours Free (after Unavailable Hours Removed):") aa = "Anna's Hours :" for (a=0;a Our program will not run just yet. We need to ad more code: the main algorithm.We will examine it in just a few minutes. Day 5 Explanation of the Constraint code The constraint code for Anna creates an array based on the number of items in the array. There 15 numbers, 9-23. The length of the array is 15. The array Anna[a] is assigned to the letter x. The first loop produces the following results x = Anna[a]9 x = Anna[a]10 x = Anna[a]11 Next array output delete Anna[a]11 x = Anna{a]12 delete Anna[a]12 x = Anna[a]13 delete Anna[a]13 x= Anna[a]14 delete Anna[a]14 x = Anna[a]15 x = Anna[a]16 x = Anna[a]17 x = Anna[a]18 x = Anna[a]19 x = Anna[a]20 x = Anna[a]21 x = Anna[a]22 x = Anna[a]23 The last section produces searchDelete(delList,Anna)11,12,13,14 If you add some window.alerts to the code you can see first hand how this code, gets the first hours, deletes the unavailable hours and the adds the rest of the hours after the deleted hours. The third window.alert shows the deleted hours //Constraint 1: Anna has classes from 11Am - 1:50pm delList = [] for (a=0;a= 11 && x <= 14){ delList.push(x) //Anna/splice(a,1) //deleteAnna[a] window.alert("deleteAnna[a] " + Anna[a]); } } //(Delete ALL of Anna's unavailable hours) searchDelete(delList,Anna) window.alert("searchDelete(delList,Anna )" + delList,Anna); Day 6 The main algorithm is added at the end of your project. Save and test. The document.writeln has been added so that the information you desire is printed onto the html document as well as the console. As you have probably noticed the variables a, b, c, d, e and f were used to represent each employee as well as the variables v, w, x, y, z and z1. //Main Algorithm: Generate and Search for(v=0;v< Anna.length;v++){ for(w = 0;w< Betty.length;w++){ for(x=0;x< Cara.length;x++){ for(y=0;y< Donna.length;y++){ for(z=0;z Our example is a simple AI problem-solving algorithm based on data contained in the arrays. The constraints eliminate some unavailable hours. The main goal of the program is stated If (g1(Anna[v], Betty[w], Cara[x], Donna[y], Jerry[z], Ashley[z1])). If all these conditions are true then the solution is displayed in the console.log stating that all these folks can meet at particular times. Debugging Tips/Completed project code JavaScript can be tricky, especially the curly braces. When using Notepad++, if you click on a beginning curly brace, it turns red and the corresponding ending brace also turns red. This is a good way to check if you have the correct number of braces surrounding the statements. This also works with parentheses. The tutorial link below has some very useful information about debugging javaScript. Debugging javaScript in Chrome Dev Tools There a number of other ways to debug javaScript code. The first method uses a breakpoint that is set in your code. Let's try this method using our AI program. Suppose we are trying to find out what is in Anna[a] array. We can key in some lines In Notepad++ setting a breakpoint using debugger; as a line of code followed by a console.log Anna([a]);. Insert these two lines into your original code as shown below. //Constraint 1: Anna has classes from 11Am - 1:50pm delList = [] for (a=0;a= 11 && x <= 14){ delList.push(x) //Anna/splice(a,1) debugger; console.log(Anna[a]); //deleteAnna[a] } } Save your file. Click on Run in Notepad++ Click on launch in Chrome. Press F12 key to activate the debugger Dev Tools Click on the Sources tab. Click on the Start Calculation button. Code execution stops on the line with the word debugger; highlighted. In the Dev Tools find the play button. It is blue in color and looks like If you over over it , it says resume script execution F8. Click on it and look in the console pane of Dev Tools. The number 11 should appear. 11 is the first hour that Anna is no available to attend a meeting. Click on the play button again and look in the console pane. You should see the number 12 under the 11. Click on it again and you will see the number 13 in the console pane window. One more click and the number 14 appears. That is the last hour that Anna is unavailable to attend a meeting. By stepping through a line of code at a time, you can gain a better understanding on how the program works as well as fixing any bugs. You can remove the debugging lines, by returning to your original code and removing these lines. The second method involves setting the breakpoint using DevTools. Click on Run in Notepad++ Click on launch in Chrome. Press F12 key to activate the debugger Dev Tools Click the line number where you want execution to stop. In this example, the line where the breakpoint was set 210 Click on the Start Calculation button. The pane at the far right, the Call Stack contains a wealth of information about the original arrays and the length of each array after the unavailable hours have been deleted. Think of the Call Stack as a data structure to do list of functions.