Skip to content

Instantly share code, notes, and snippets.

View sleeptil3's full-sized avatar

Shawn Clary sleeptil3

  • Cape Coral, FL
View GitHub Profile
@sleeptil3
sleeptil3 / gist:332c356b7b864b91a760dce616359749
Last active July 30, 2021 04:33
Heroku CLI Deploy using GitHub
##################################################################
# #
# README: #
# #
# This assumes that you have not yet created the app on Heroku, #
# your publish-ready project is git initialized and committed, #
# and you are in the base directory of the project. #
# #
##################################################################
@sleeptil3
sleeptil3 / array_reduce_example.js
Last active September 20, 2021 18:29
Array Reduce Example
// Prompt: take an array called "cards" that is a hand in a card game populated with card Objects and return an Object that sorts the cards according to suit (i.e. the key will be the suit name and the value will be an array of face values of that suit)
/*
- On line 20, you can see I'm setting the default value of the accumulator to an empty Object {} and naming the argument "suits" for clarity
- This is because the default value of the accumulator is 0, but since I want the reducer to return an Object, you indicate that here to override the default behavior.
- The conditional on line 17 checks if the current suit already exists in the suits Object, and if not, creates an empty array to receive it
*/
const card1 = { value: "9", suit: "hearts" }
const card2 = { value: "K", suit: "hearts" }