Post image
Light Mode
Dark Mode
JavaScript Horizons: Core, Canvas, Futures & Cookies

Hello, checkiomates🐱‍👤!

We dive into essential JavaScript practices by comparing when and how to use map versus forEach effectively, explore the fascinating world of creating gradients with WebGL for advanced graphics, and highlight key features every JavaScript developer should know heading into 2025. Additionally, we present a unique and challenging mission: helping the Cookie Monster devour piles of cookies in the fewest possible moves following the Count's very specific, peculiar rules.

💡TIP

If you find an interesting solution, you may add it to your bookmarks by clicking the flag near solution title. You can find all your bookmarked solutions by clicking your nickname and then "Bookmarks".
If you want to discover all CheckiO features, visit our tutorial. It's a longread, but it's worth it!

🏁MISSION

The Cookie Monster by freeman_lex -

The beloved Cookie Monster from Sesame Street has stumbled upon a table with sorted piles of cookies, each pile a positive integer. However, the monomaniacal obsessiveness of the Count who set up this crumbly fiesta has recently escalated to a whole new level of severity. The Count insists that these cookies must be eaten in the smallest possible number of moves. Each move chooses one of the remaining pile sizes p, and removes p cookies from every pile that contains at least p cookies (thus eradicating all piles with exactly p cookies), and leaves all smaller piles as they were.
Since the Count also has an unhealthy obsession with order and hierarchies, he expects these moves to be done in decreasing order of values of p. This function should return the array of moves, that allows Cookie Monster to scarf down these cookies. If there are a few optimal sequences of moves, choose the lexicographically largest one. Look at the example for [1, 2, 3, 4, 5, 6] input.

assert.deepStrictEqual(cookieMonster([1, 2, 3]), [2, 1]);
assert.deepStrictEqual(cookieMonster([1, 2, 3, 4, 5, 6]), [4, 2, 1]);

📖ARTICLE

When to use map() vs. forEach() -

A common task developers perform is iterating over arrays. And two of the most frequently used methods for this are map() and forEach(). Both seem similar, but the differences can significantly affect how your code behaves. Let’s take a closer look at both and why I think map() wins out as the better choice when transforming data.

A flowing WebGL gradient, deconstructed -

Even if you don’t want to render a neat plasma-style effect on the Web, this is a wonderfully deep exploration of the math and technology behind doing so using simple GLSL code that could be easily understood by any JavaScript developer.

Some features that every JavaScript developer should know in 2025 -

JavaScript is constantly evolving and newer features are introduced. This oftentimes makes older coding practices outdated, and even less efficient. Bellow is a list of some important features (old and new) that most developers might be unaware of.

👩‍💻CODE SHOT

How do you think, what the following code does?

function ????????(data: Object): Object {
    const result = {};
    for(const [key, val] of Object.entries(data)){
        result[val] = (result[val] ?? new Set()).add(key);
    }
    return result;
}

🙌 Thanks for your attention! Hope to meet you at CheckiO, as well as at our Instagram and Twitter! We are really interested in your thoughts! Please, leave a comment below! ⤵

Created: April 29, 2025, 4:53 p.m.
0
17
User avatar
freeman_lex