diff --git a/Week8-master/README.md b/Week8-master/README.md new file mode 100644 index 0000000..0e3e294 --- /dev/null +++ b/Week8-master/README.md @@ -0,0 +1,67 @@ +# Week8 - Chatbot + +See the instructions [here](https://docs.google.com/document/d/1123vh08osRkCyqsnyR0SQMC1n4l0DlDIS0OYSrPSlY0/edit?usp=sharing) for the first part of your chatbot, or read below: + +**Due Date: Sunday, September 15 at 6:00 p.m.** + +Complete the following assignment and create a pull request to GitHub for reviewing by the instructor. + +The homework assignments for the next few lectures will be interconnected. By the end of JavaScript 2, you will have developed a fully functional chatbot. These assignments will build on the previous week's assignment, therefore, it is very important that you complete the assignment in a timely manner (i.e. by the due date). + +## CHATBOT PART I + +In this first assignment, you will begin by building a very simple chatbot. As you progress through the remaining JavaScript weeks, you will add more and more functionality to the chatbot. + +You are provided the HTML and CSS code for this assignment in this repository. Your task will be to write the JavaScript portion to make the chatbot functional and interactive. Remember to add comments to your code, describing what it does. + +1. In your JavaScript code, declare a variable and initialize it as an object. +2. Add two properties to the object: ‘input’ and ‘output’. + 1. To the ‘input’ property/key assign a greeting or a question that you want the chatbot to reply to. Some examples are: + * Hello + * How are you? + * What is your favourite colour? + 2. To the ‘output’ property/key assign answers to the greetings or questions you wrote in part a. Some examples to the inputs above are: + * Hi + * Great! + * I have so many favorites it's hard to choose one. +3. console.log() your variable to confirm that you have assigned the values correctly. If done correctly, you output should look similar to: +```js +{ input: 'input1', output: 'output1' } +``` + +4. Below your variable declaration, create a function called ‘reply’. +5. In the ‘reply’ function, declare a variable called ‘question’ and assign to it the **value**of the HTML `` element. + - HINT: use the id assigned to the `` element to get access to the element. +6. Use a conditional statement to check if the value you stored in the 'question' variable matches the 'input' defined in the object you first created. + 1. If it does, assign the corresponding output to the **value** of the + + + + + \ No newline at end of file diff --git a/Week8-master/javaScript.js b/Week8-master/javaScript.js new file mode 100644 index 0000000..c9477fe --- /dev/null +++ b/Week8-master/javaScript.js @@ -0,0 +1,18 @@ + +var myObject = {input:"Hi", output:"Bye"}; +console.log(myObject); + +function reply(){ + var question = document.querySelector ("#input"); + + +} + +if (myObject == "#input") { + return ("#output") + else (myObjext !== "#input") + return ("I don't understand that command. Please enter another") + +} + +document.getElementById("#submit").addEventListener("click", myObject); diff --git a/Week8-master/style.css b/Week8-master/style.css new file mode 100644 index 0000000..b4c8731 --- /dev/null +++ b/Week8-master/style.css @@ -0,0 +1,52 @@ +button { + font-family: Helvetica; + font-size: 10pt; + width: 92px; +} + +textarea { + font-family: arial; + font-size: 10pt; +} + +body { + color: #333; + background-color: #efefef; + font: 13px helvetica, arial, freesans, clean, sans-serif; +} + +#demo { + width: 80%; + max-width: 1000px; + margin-left: auto; + margin-right: auto; + padding: 20px; + background-color: #F8F8F8; + border: 1px solid #ccc; + box-shadow: 0 0 10px #999; + line-height: 1.4em; + font: 13px helvetica, arial, freesans, clean, sans-serif; + color: black; +} + +#demo input { + padding: 8px; + font-size: 14px; + border: 1px solid #ddd; + width: 400px; +} + +#demo textarea { + padding: 8px; + font-size: 14px; + border: 1px solid #ddd; + width: 800px; +} + +input:focus { + outline: none; +} + +textarea:focus { + outline: none; +} \ No newline at end of file