This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Given two absolute paths on a file system, write a function to determine the difference between them. | |
// For example, `/a/b/c` and `/a/d` should yield `../../d`. | |
// `/a/b/c` and `/e/f` => `../../../e/f` | |
// `/` and `/a/b/c` => `/a/b/c` | |
// `/a/b/c` and `/` => `../../../` | |
function difference(path1, path2) { | |
// break the paths into lists and discard the first empty element |
OlderNewer