Skip to content

TinaCollier/orderDrink

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

orderDrink

using a callback function to order a drink

Callback Functions

The purpose of this challenge was to create a callback function. A callback function uses another function as a parameter. In my code, I used a function to determine my favorite drink based on the daily temperature. Then, I passed that function into another function as a parameter that identified if my favorite drink was an option in an array of drink options. Lastly, it printed my drink order for me based on if my drink was available or not.

What Was Challenging

The most challenging part was figuring out how my function would determine what my drink choice was. I also needed to find a way to identify if my favorite drink was available. For this, I used the .includes method.

What I Would Do Differently

I spend a long time on this challenge, but it helped me better understand how callback functions work. In my second callback function, I used setInterval and passed an anonymous function. This was much simpler and quicker to write. Next time, I write a callback function, I hope to be able to do it in much less time.

About

using a callback function to order a drink

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages