Sobes.tech

Do you have experience in independently designing the architecture of a service or its part?

139

// Implement the groupBy method that extends the standard array methods. // The method should return a grouped version of the array – an object, // where each key is the result of the function fn(arr[i]), // and each value is an array containing all elements of the original array with this key.

135

/* We have a set of tickets of the following form: [ { from: 'London', to: 'Moscow' }, { from: 'NY', to: 'London' }, { from: 'Moscow', to: 'Spb' }, ... ] From these tickets, a single continuous route can be constructed. There are no loops or repetitions in the route. Write a program that returns these ticket objects in the order of the route. */ function getRoute(tickets = [], startCity = 'NY') { // your code here }

122

/** * The function `asyncAuth(callback)` accepts a callback, which can * be passed an error (as the first argument) and data * from the backend (as the second argument). * asyncAuth((error, data) => {}); * * You need to implement the `auth()` function, * which calls `asyncAuth()`, but returns a Promise. * * @returns {Promise} */ export function auth() { // asyncAuth((error, data) => {}); } /** * The function `tryAuth()` uses `auth()` and, in case of an error, * makes N additional attempts. * If all attempts fail - throw the last error * * @returns {Promise} */ export function tryAuth(n) { }

116
/2