Skip to content

Instantly share code, notes, and snippets.

@halitbatur
Created March 23, 2023 17:11
Show Gist options
  • Save halitbatur/7d0ea3315d891b0c621741f2575c6aa3 to your computer and use it in GitHub Desktop.
Save halitbatur/7d0ea3315d891b0c621741f2575c6aa3 to your computer and use it in GitHub Desktop.
first-class functions
  1. What is a first-class function, and how does it differ from other types of functions?
  2. How can first-class functions be used in JavaScript to pass functions as arguments to other functions?
  3. Explain the difference between array.map(), array.reduce(), and array.filter(). In what scenarios would you use each of these array methods?
  4. Write a function that uses array.map() to double every number in an array. How would you modify the function to triple every number instead?
  5. Write a function that uses array.filter() to return only the even numbers in an array. How would you modify the function to return only the odd numbers instead?
  6. Write a function that uses array.reduce() to find the sum of all the numbers in an array. How would you modify the function to find the product of all the numbers instead?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment