58 challenges match these filters
addRounded(a, b) should add two numbers and return the result rounded to two decimal places, as a number. addRounded(1, 2) is 3.
Other
stripDashes(text) should remove every dash, so stripDashes("a-b-c") returns "abc".
Other
isAvailable(item) should be true only when the item is in stock AND not discontinued.
Logic error
percentChange(oldValue, newValue) should report the change as a percentage of the old value. Going from 100 to 150 is +50.
Logic error
joinWithDash(words) should join words with dashes between them, so joinWithDash(["a","b"]) returns "a-b".
Off-by-one
pageItems(items, page, size) returns one page of results. Pages are numbered from 1, so pageItems([1,2,3,4,5,6], 1, 3) gives [1,2,3].
Off-by-one
sumAll(nums) should add up every number in the array, so sumAll([1, 2, 3]) returns 6.
Off-by-one
cityOf(user) should return the user's city, or "unknown" if any part of the path is missing.
Null / Undefined
priceOf(items, name) should return the named item's price, or 0 when there is no such item.
Null / Undefined
greet(user) should greet the user by name, falling back to "guest" when no name is available.
Null / Undefined
retriesFor(settings) should use settings.retries when it is provided and fall back to 3 when it is missing. Setting retries to 0 means 'do not retry'.
Null / Undefined
countUnique(records) should count distinct records by their contents, so two records with the same fields count once.
Type error
describeType(value) should name the type of a value, returning "null" for null and "object" for real objects.
Type error
sumPrices(prices) should total a list of price strings, so sumPrices(["1.5", "2.5"]) returns 4.
Type error
countZeros(values) should count how many entries are the number zero, so countZeros([0, "", false, 0]) returns 2.
Type error
countUppercase(text) should count the uppercase letters, so countUppercase("aBc") returns 1.
Infinite loop
stepsToExceed(limit) counts how many times you must double 1 before passing limit, so stepsToExceed(8) returns 4.
Infinite loop
indexOfValue(sorted, target) should return the index of target in a sorted array, or -1 if it is absent.
Infinite loop
countOdds(nums) should count the odd numbers, so countOdds([1, 2, 3]) returns 2.
Infinite loop
countMatches(words, target) should count how many times target appears, so countMatches(["a","b","a"], "a") returns 2.
Scope error
Each tracker from makeTracker() should start at zero, so trackTwice(5, 3) returns 3 — the second tracker's own total.
Scope error
priceWithFee(base) should add a flat fee of 5 to the base price, so priceWithFee(10) returns 15.
Scope error
countAll(items) should count how many items were passed in, so countAll([1, 2, 3]) returns 3.
Scope error
describe(useLocal) should return "local" when useLocal is true and the outer "global" when it is false.
Scope error