Bentley Systems Interview Question

To write the Javascript code