Hattie Times Website

Entry #5 (4/16):
I had a rather frustrating week with my codesketch; after feeling really confident after class about arrays/event listeners/functions, I was excited to implement my own array, but encountered so many problems. My idea was to do a “choose your comfort food” array, with all sorts of fun teas, coffees, and snacks that would appear after every click, but I couldn’t figure out how to do it. I created my array, with my variable of food pointing towards the various images of my snacks, in brackets. My other variable, food choice, was designed to get the images when clicked, using an event listener. After our lesson on Monday on how to create a randomizer-function (using math.random, times the number of values you have in your array, and then using math.round to round the number to a whole value), I added this in to get a random image every time clicked, but with no success! My goal was to change the background image of my div/variable “foodchoice,” yet nothing seemed to work! My code seems to be exactly the same as Molly’s for her color randomizer, just with different variables, and yet it still doesn’t seem to be working. I tried to go into the console and input “food” to see if my values appeared, but it continued telling me that the variable food is undefined. I’m going to keep trying to troubleshoot over the weekend and hopefully figure out the issues next week.