Lab 8 - Anon Functions & Callbacks

Challenge

The challenge for this assignment is to use callbacks and anonymous functions inside of callbacks.

Problems

For the most part, everything was easy because I had already went through them in the previous lab. I already knew how to use document.getElementById, but didn't realize that you could just use any id instead of one that is in span. However, I decided to go for a more uniform approach because I ended up not liking how the formatting looked despite it working. To make it harder on myself, I experimented with a new command called "if", which in this case would ascertain whether or not the result of a function's operation is true or false. I troubleshooted this beforehand with ChatGPT and found that I could simply just do if (result) instead of if (result = true) or if (result === true).

Results

Down below are the results of my experiment.

Script Output

Here is an array of numbers:

Here are those numbers split in half:

Here is an array of random anmes:

I'm checking if these names are even or odd... Here are the results of my analysis:

You can check if the names are even or odd by inspecting the page and clicking console.