Sobes.tech

What are the advantages and disadvantages of functional programming?

Senior
227

When will you be able to start working if you receive an offer?

Senior
227

What is the difference between INNER JOIN and LEFT JOIN? What happens to the row from the left table if there is no corresponding row in the right table?

Senior
191

What does it mean for a team to be idempotent?

Senior
178

Implement one or both functions in the application: a user can pin and unpin sites with an icon in the list; pinned sites should be displayed at the top of the list. The second function is optional at your discretion.

Senior
171

Why do you want to change the company right now?

Senior
165

What is the difference between the || operator and the ?? operator in JavaScript/TypeScript? What will happen if retryLimit is set to 0?

Senior
153

Delete a comment app.delete('/comments/:id', requireAuth, async (req, res) => { const comment = await db.comments.findById(req.params.id) if (!comment) { return res.status(404).end() } await db.comments.delete(comment.id) res.status(204).end() }) Paginate a list function paginate<T>(items: T[], page: number, pageSize: number): T[] { const start = page * pageSize const end = start + pageSize return items.slice(start, end) }

Senior
118

Have you ever written unit tests? To what extent?

Senior
98

Spot the bug · TypeScript Sneaky Errors Each of these eight snippets compiles, passes a casual review, and looks fine. Every one hides a bug. For each: tell us what breaks, under what conditions — and how you'd catch it. Think out loud. We're interested in how you read code, not in a stopwatch. It's fine not to nail every one. 01 Placing an order interface Notifier { send(to: string, message: string): Promise<void> } class OrderService { constructor(private readonly notifier: Notifier) {} async placeOrder(order: Order): Promise<OrderId> { const id = await this.repo.save(order) this.notifier.send(order.customerEmail, `Order ${id} confirmed`) return id } } 02 Updating a profile app.post('/profile', async (req, res) => { const profile = parseProfile(req.body) try { await db.profiles.update(req.user.id, profile) } catch (err) { logger.warn('profile update failed', err) } res.status(200).json({ status: 'saved' }) }) 03 Deleting a comment app.delete('/comments/:id', requireAuth, async (req, res) => { const comment = await db.comments.findById(req.params.id) if (!comment) { return res.status(404).end() } await db.comments.delete(comment.id) res.status(204).end() }) 04 Paginating a list function paginate<T>(items: T[], page: number, pageSize: number): T[] { const start = page * pageSize const end = start + pageSize return items.slice(start, end) } // caller const results = paginate(rows, page, 20) // page starts at 1 in the UI 05 Loading articles with authors async function loadArticlesWithAuthors(): Promise<ArticleView[]> { const articles = await db.query('SELECT * FROM articles WHERE published = true') const views: ArticleView[] = [] for (const article of articles) { const author = await db.query('SELECT * FROM users WHERE id = $1', [article.authorId]) views.push({ ...article, author: author[0] }) } return views } 06 Resolving config defaults interface Settings { retryLimit?: number displayName?: string } function resolveConfig(s: Settings) { return { retryLimit: s.retryLimit || 3, displayName: s.displayName || 'Anonymous', } } 07 Testing a discount helper function applyDiscount(price: number, percent: number): number { return price - price * (percent / 100) } describe('applyDiscount', () => { it('applies a discount', () => { const spy = vi.fn().mockReturnValue(90) const result = spy(100, 10) expect(result).toBeDefined() expect(result).toBe(90) }) }) 08 Computing top scores function topScores(scores: number[], take = 3): number[] { return scores.sort((a, b) => b - a).slice(0, take) } const results = [4, 1, 9, 2] const podium = topScores(results) // ... later, elsewhere: renderRawResults(results) // expected [4, 1, 9, 2]

Senior
79