Is there a way to have the code print just the last item in an array?
Sure! You can do that like this:
console.log(array[array.length - 1])
array representing the name of the array you want to print.
array.length - 1 is the number of items in the array, minus
For example, if the array
3 items in it:
let animals = ['dogs', 'cats', 'whales']
'dogs' is at
'cats' is at
'whales' is at
console.log(animals[animals.length - 1])
This is the same as printing out
Hope that helps! Let me know if you have any questions.