From 2b9d08e6a021bb6a04ad32a96e1f3a4c5ab0a879 Mon Sep 17 00:00:00 2001 From: hamzakoc Date: Sun, 15 Sep 2019 14:05:59 -0400 Subject: [PATCH 1/6] week8 homework submission --- index.html | 2 ++ script.js | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 script.js diff --git a/index.html b/index.html index 4793879..3008406 100644 --- a/index.html +++ b/index.html @@ -2,6 +2,8 @@ My First Chatbot + + diff --git a/script.js b/script.js new file mode 100644 index 0000000..24fb2b3 --- /dev/null +++ b/script.js @@ -0,0 +1,33 @@ + +//properties added to the object: ‘input’ and ‘output’ as an array + +var chatbot = { + input: ["hello", "how are you", "how is your day", "what do you do"], + output: [ "hi", "greaatt!", "good", "software developer" ] + }; + +//print variable +//console.log(chatbot); + +//created a function called ‘reply’. +function reply() { + let question = document.getElementById("input").value.toLowerCase(); + +//conditional statement + if (chatbot.input[0] === question) { + document.getElementById("output").value = chatbot.output[0] + } else if (chatbot.input[1] === question) { + document.getElementById("output").value = chatbot.output[1] + }else if (chatbot.input[2] === question) { + document.getElementById("output").value = chatbot.output[2] + }else if (chatbot.input[3] === question) { + document.getElementById("output").value = chatbot.output[3] + } else { + document.getElementById("output").value = "Enter a valid value" + } + +} + + +//attach a 'click' event listener to the