This project contains 2 solved questions
Write a function called deepClone which takes an object and creates a copy of it. e.g. {name: "Paddy", address: {town: "Lerum", country: "Sweden"}} -> {name: "Paddy", address: {town: "Lerum", country: "Sweden"}}
We'd like to contact partners with offices within 100km of central London (coordinates 51.515419, -0.141099) to invite them out for a meal.
Write a NodeJS/JavaScript program that reads our list of partners (download partners.json here) and outputs the company names and addresses of matching partners (with offices within 100km) sorted by company name (ascending).
You can use the first formula from this Wikipedia article to calculate distance. Don't forget to convert degrees to radians! Your program should be fully tested too.
This project is implemented in NodeJS and tested on versions v8, v9 and v10
-
Download all the files in this gist to a folder
- In order to ease this step I have uploaded the folder structure to dropbox and can be downloaded from here
-
To install dependencies(only testing packages, as can be checked from
package.json
) typenpm install
-
To run test cases, run
yarn run test
- Question1:
- Source module:
getInviteCandidates
ininvitePartner.js
. - Driver file:
invitePartner-driver.js
- Test file:
test_invitePartner.js
- Source module:
- Question2:
- Source module:
deepClone
indeepClone.js
. - Driver file:
deepClone-driver.js
- Test file:
test_deepClone.js
- Source module:
Driver files are a demo of module usage