Ctrl K
QA · Junior · Coding

In a catalog UI test, after sorting by price you need to check the order of the products. Write a helper function isSortedByPrice: it takes a list of products, each with a price, and a direction, ascending or descending, and returns true if the list is sorted. Then show how to call it in the test's assertion.

~15 min by voice

How to approach it

They're checking whether you can write a simple but correct order check: a pairwise non-strict comparison of neighbors, both directions, edge cases. And whether you can build it into a test so the test doesn't pass vacuously and it's clear what broke when it fails.

Have you seen this question in a real interview?
Answers0
Avg. score—
Strong—
Practiced0
Topics

Answer by voice

The interviewer will ask this question and listen. Think out loud and ask for a hint if you need one. When you're done, pause or tap “That's my answer”. In about a minute, your score and the points you covered show up here.

Sign in to answer

Best with headphones · ~15 min