SShortSingh.
Back to feed

JavaScript Chapter 3: Using Conditions and Avoiding Comparison Traps

0
·6 views

This chapter of a beginner JavaScript course teaches readers how to make programs choose between paths using conditional logic. It uses an airline baggage-fee example, where a script that charges every passenger a surcharge caused costly refunds and lost staff trust. The lesson introduces Boolean values and comparison operators such as greater-than and greater-than-or-equal, then shows how if and else blocks route execution. It also warns that loose equality (==) performs type conversion that can cause hidden bugs, so strict equality (===) is recommended. Readers are asked to confirm their Node.js setup first, as covered in Chapter 1.

Read the full story at DEV Community

This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)

Log in to join the discussion and vote.

Log in

Related stories

0
ProgrammingDEV Community ·

SQL Server 2026 Licensing: When Standard Suffices and When Enterprise Is Worth It

A comparison of SQL Server Standard and Enterprise licensing shows a 16-core server costs about $31,560 under Standard versus $120,984 under Enterprise at 2026 list prices. Standard now supports up to 32 cores and 256 GB of memory, which removes the need for Enterprise in many workloads. Enterprise is justified mainly by online index rebuilds, full Always On availability groups with readable secondaries, or scale beyond Standard's limits. The article also covers per-user CAL alternatives, Azure licensing options such as Azure Hybrid Benefit, and common overspending mistakes. Prices are list prices and actual costs depend on agreements and resellers.

0
ProgrammingDEV Community ·

Making n8n AI Workflows Production-Ready With Queue Mode and Webhook Security

Running n8n AI workflows under real production load is much harder than building them locally, since traffic spikes can drop connections and upstream LLM errors can halt chains midway. Exposed unauthenticated webhooks also risk replay attacks and unauthorized payloads. The article recommends decoupling webhook intake from execution using Redis queue mode with separate worker containers, so compute-heavy tasks don't crash the main instance. It also advises verifying HMAC signatures on incoming webhooks before any LLM or database step runs. Finally, it suggests structured fallback routing to handle rate limits and transient provider outages without expensive model overuse.

0
ProgrammingDEV Community ·

Finding Chinese Characters in GBase 8a Using REGEXP

In the domestically developed GBase 8a MPP database, the REGEXP operator can locate rows containing Chinese characters, provided the column uses the UTF8mb4 character set. The article demonstrates two equivalent queries that return the same four matching rows from a seven-row test table mixing ASCII, digits and Chinese text. One approach writes the CJK character range directly into the SQL, which depends on the client connection carrying those bytes correctly. The alternative encodes the same range as a hexadecimal UTF8mb4 byte sequence, keeping the SQL pure ASCII and avoiding encoding issues in shells, scripts or drivers. The author notes the hex form is the safer default in such cases, though it is less readable and should be accompanied by a comment explaining the decoded range.

0
ProgrammingDEV Community ·

Developer builds zero-dependency browser tool for generating banners, logos and badges

A developer created a small browser-based tool that produces consistent sets of banners, logos and badges without requiring libraries, uploads, or signups. The first version relied on html2canvas, but it was replaced with a native 2D canvas implementation that outputs full-resolution PNGs at platform-specific sizes. The tool offers fixed presets for platforms such as YouTube, Twitter/X, GitHub, Discord and Open Graph, plus custom dimensions, two-color backgrounds with an optional gradient, and a copyable HTML snippet. Designs are saved in localStorage so unfinished work survives page refreshes. The author notes the tool is not a full design application like Figma, as it lacks layers, freehand drawing and vector editing.