Hello! Thank you for taking the time to complete the Versus Systems coding challenge. Feel free to reach out if anything below is unclear, otherwise we look forward to reviewing your submission!
Time: Please don't spend more than an hour or so on this. If you find yourself starting to take longer than that, feel free to stop coding and jot down your next steps in note form — they can serve as a discussion point during the in-person phase of your interview.
Language: We're an Elixir shop, but feel free to use any server-side language you feel comfortable with (Ruby, Java, Python, Node, etc). We care more about seeing clean, well-structured code than we do about seeing any particular language.
Deliverables: When you're done, please send us either a ZIP file or a link to a Github repo with your code. Either way, make sure to include a README explaining how to run it.
All data that flows in or out of our API gets saved to a log. This is helpful when debugging, but unfortunately means that all of our users' personal information gets stored in plain text. In order to respect our users' privacy, we need to clean this up.
To handle this, you must write a scrub function to remove all personal information from a piece of data before it is logged. This function will take in an object and perform the following transformations:
- replace all "name", "username", and "password" values with the string "******"
- for all "email" fields, replace only the username (the part before the @)
Assume that personal data can be nested inside objects or arrays at any depth. The final result should behave like this (the example below is in json, but you can assume the function will be called with data types native to the language of your choice):
| Example In | Example Out |
|---|---|
{
"id": 123,
"name": "Elsa",
"username": "xXfrozen_princessXx",
"email": "elsa@arendelle.com",
"age": 21,
"power": "ice ray",
"friends": [{
"id": 234,
"username": "MagicSnowman32"
}, {
"id": 456,
"username": "call_me_anna"
}]
}
|
{
"id": 123,
"name": "******",
"username": "******",
"email": "******@arendelle.com",
"age": 21,
"power": "ice ray",
"friends": [{
"id": 234,
"username": "******"
}, {
"id": 456,
"username": "******"
}]
}
|
Good luck, and happy coding!