Multi-Tasking

worker counting stocks in warehouse

There are times in programming where you need to check conditions against multiple items. If statements are used to do this a lot. We could do this by nesting if statements and performing the code if they return true as follows…

if(this === that){
    if(who === what){
        doSomething();
    }
}

While this works, nesting can get hairy and confusing. There is a way that could be simpler. We can use the and (&&) operator to check two conditions. Here is a revision of the previous code…

if(this === that && who === what){
    doSomething();
}

The previous example shows how to compare two separate condition statements, but you can put together multiple conditions.

On a related note, you can also use the or (||) operator to utilize either/or logic.

Happy Coding!

Clay Hess

More To Explore

Crisis. Concept of reducing costs. Bag with dollars money in vise.
Code

Compression Streams API: Native gzip/deflate for the web

The Compression Streams API brings native, streaming gzip and deflate to the web platform. With built‑in CompressionStream and DecompressionStream, you can compress or decompress data on the fly—no third‑party libraries required. It integrates cleanly with Fetch/Response to turn streams into ArrayBuffer, Blob, Uint8Array, String, or JSON, works in Web Workers, and is part of the 2023 Baseline. Use it to shrink uploads, store compressed data offline, and streamline real‑time pipelines while keeping bundles lean.

Share This Post

small_c_popup.png

Need help?

Let's have a chat...


Login

Jump Back In!

Here at Webolution Designs, we love to learn. This includes sharing things we have learned with you. 

Register

Begin Your Learning Journey Today!

Come back inside to continue your learning journey.