I have taken advice from previous questions I asked about adding mp3 files to my javascript code and came up with this.
var howrutday = new Audio('file:///C:/This_PC/Music/Science_Fair_Robot/howrutday.mp3');
var name = function (robot) {
if ('Hi.' + 'Hi!' + 'Hello.' + 'Hello!' + 'Greetings.' + 'Greetings!') {
console.log("How are you doing today " + name + "?");
howrutday.play();
} else if ('Good morning.' + 'Good morning!') {
console.log("How are you doing today " + name + "?");
} else if ('Good afternoon.' + 'Good afternoon!') {
console.log("And to you also, what a lovely day.");
} else if ('Good evening.' + 'Good evening!') {
console.log("How was your day?");
} else if ('Good night.' + 'Good night!') {
console.log("Rest well " + name + ". I hope to see you tomorrow.");
} else {
console.log("Try saying that again but make sure you are using proper grammar like applying punctuation and capitalization.");
}
I'm not sure if it's a problem with my syntax or if I'm not making my audio file visible to the program. Also does anybody have recommendations for websites to run my code in because maybe the one I'm using does not play audio. Just a theory though.