Skip to content

Instantly share code, notes, and snippets.

@davidchase
Last active May 16, 2022 18:49
Show Gist options
  • Save davidchase/9bae0320169b57f99a77ab0a3bb79322 to your computer and use it in GitHub Desktop.
Save davidchase/9bae0320169b57f99a77ab0a3bb79322 to your computer and use it in GitHub Desktop.
// how would you programmatically create a list of 3 elements and set to the DOM
// the data should come from a external entity like a third party source ie https://reqres.in/api/users
/*
should result into
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
</ul>
*/
// how would you implement the following function?
/*
add(10, 10) // 20
add(10)(10) // 20
var addTen = add(10)
addTen(10) // 20
**bonus** implement a general function that will provide the same result ie:
const add = myFn((a, b) => a + b)
add(10, 10) // 20
add(10)(10) // 20
const sub = myFn((a, b) => a - b)
sub(20, 10) // 10
sub(20)(10) // 10
*/
// how would you implement a function based event emitter?
/*
listen(console.log)
emit(10)
emit(100)
**bonus** implement a way to unsubscribe the listen function
const unsubscribe = listen(console.log)
unsubscribe() // will remove the listener
*/
// how would you implement a Map that supports single key with multiple values?
/*
so the following could be possible
const map = new SpecialMap()
map.set('a', 1)
map.set('a', 2)
map.size // 2
*/
// given the following functions how would you make the following string work?
/*
const reverseIt = str => str.split('').reverse().join('')
const exclaim = str => `${str}!`
const capitalize = str => str.replace(/\b\w/g, l => l.toUpperCase())
const trimIt = str => str.trim()
const str = `hello | reverseIt | exclaim | capitalize | trimIt` // "Olleh!"
*/

Theme:

  • Single vs Multi Tenant

Scenario based questions:

  • You have a backend service + database that is accessed by a tenant's id However some of this data needs to be provided to the frontend without exposing that id. This data on the frontend is need for bootstrapping some of the frontend services. How would you address this task?

  • Client has a need to publish articles using a 3rd party API that allows you to build an article and provide content to it. The cavet is in order to build an article you have to make a sequential request to the API to first create the article category, section and finally the body with the content. What would use? How could you scale so that client could publish many articles at once?

  • Client needs to onboard new customers. During the discovery phase they notice that are multiple business domains that are affected by the onboarding process. So now the question becomes what pattern can we use here, we can build a centralized service that maintains any and all domains logic that pertains to the onboarding phase or we can leave it to the business domains to coordinate and build services that expose APIs and other entities that will be operated during onboarding.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment