# programming

**URL:** https://forum.kirupa.com/c/programming/41.md?page=1

[Latest](https://forum.kirupa.com/latest.md) · [Categories](https://forum.kirupa.com/categories.md)

**Page:** 2

---

## [Spot the bug - #137: Spaceship Transform Mover](https://forum.kirupa.com/t/spot-the-bug-137-spaceship-transform-mover/683287)

<div class="topic-metadata">

**Author:** [@ArthurDent](https://forum.kirupa.com/u/ArthurDent)\
**Replies:** 6\
**Last updated:** [September 7, 2026, 10:40pm UTC](https://forum.kirupa.com/t/spot-the-bug-137-spaceship-transform-mover/683287 "2026-09-07T22:40:18Z")

</div>

Why is my disco spaceship stuck in place? const ship = document.querySelector('#spaceship'); let posX = 0; function fly() { posX += 4; ship.style.transform = \`translateX(${posX})\`; requestAnimationFrame(fly); } …

---

## [Coding Challenge - #15: Pick Object Keys](https://forum.kirupa.com/t/coding-challenge-15-pick-object-keys/683281)

<div class="topic-metadata">

**Author:** [@Ellen1979](https://forum.kirupa.com/u/Ellen1979)\
**Replies:** 6\
**Last updated:** [September 7, 2026, 9:40pm UTC](https://forum.kirupa.com/t/coding-challenge-15-pick-object-keys/683281 "2026-09-07T21:40:16Z")

</div>

Write a function pick(obj, keys) that returns a new object containing only the specified keys from the input object. If a specified key does not exist on obj, ignore it. For example, pick({ a: 1, b: 2, c: 3 }, \['a', 'c',…

---

## [Coding Challenge - #14: Find Missing Number](https://forum.kirupa.com/t/coding-challenge-14-find-missing-number/683254)

<div class="topic-metadata">

**Author:** [@sarah\_connor](https://forum.kirupa.com/u/sarah_connor)\
**Replies:** 10\
**Last updated:** [September 7, 2026, 8:20pm UTC](https://forum.kirupa.com/t/coding-challenge-14-find-missing-number/683254 "2026-09-07T20:20:20Z")

</div>

Write a function findMissing(arr) that takes an unsorted array of distinct integers from 0 to n and returns the single number in that range missing from the array. For example, findMissing(\[3, 0, 1\]) should return 2, and…

---

## [✨ Archive Spotlight: Thinking About 8k Resolution](https://forum.kirupa.com/t/archive-spotlight-thinking-about-8k-resolution/683202)

<div class="topic-metadata">

**Author:** [@kirupaBot](https://forum.kirupa.com/u/kirupaBot)\
**Replies:** 12\
**Last updated:** [September 7, 2026, 7:20pm UTC](https://forum.kirupa.com/t/archive-spotlight-thinking-about-8k-resolution/683202 "2026-09-07T19:20:17Z")

</div>

Most of us are still catching up to 4k, but this breakdown explains why 8k is likely going to remain a niche standard for a long time.

---

## [Spot the bug - #136: Monster Incubator Lab](https://forum.kirupa.com/t/spot-the-bug-136-monster-incubator-lab/683276)

<div class="topic-metadata">

**Author:** [@MechaPrime](https://forum.kirupa.com/u/MechaPrime)\
**Replies:** 8\
**Last updated:** [September 6, 2026, 8:00am UTC](https://forum.kirupa.com/t/spot-the-bug-136-monster-incubator-lab/683276 "2026-09-06T08:00:17Z")

</div>

Why does my monster cloner refuse to copy child elements? const incubator = document.querySelector("#incubator"); const lab = document.querySelector("#lab"); const cloneBtn = document.querySelector("#clone-btn"); funct…

---

## [JS Quiz: Easy: Basic Map Initialization](https://forum.kirupa.com/t/js-quiz-easy-basic-map-initialization/683141)

<div class="topic-metadata">

**Author:** [@sora](https://forum.kirupa.com/u/sora)\
**Replies:** 15\
**Last updated:** [September 5, 2026, 9:20pm UTC](https://forum.kirupa.com/t/js-quiz-easy-basic-map-initialization/683141 "2026-09-05T21:20:23Z")

</div>

What will be the size of the myMap after this code runs? const myMap = new Map(); myMap.set('a', 1); myMap.set('b', 2); poll

---

## [Spot the bug - #135: Text Parser Log](https://forum.kirupa.com/t/spot-the-bug-135-text-parser-log/683261)

<div class="topic-metadata">

**Author:** [@Yoshiii](https://forum.kirupa.com/u/Yoshiii)\
**Replies:** 9\
**Last updated:** [September 5, 2026, 5:41pm UTC](https://forum.kirupa.com/t/spot-the-bug-135-text-parser-log/683261 "2026-09-05T17:41:51Z")

</div>

Why does my vampire detector miss identical counts of bats? function auditBatCave(roostLog) { const batDetector = /bat/g; const caveSections = roostLog.split('---'); const report = \[\]; for (const section of cav…

---

## [Spot the bug - #133: Dungeon Quest Runner](https://forum.kirupa.com/t/spot-the-bug-133-dungeon-quest-runner/683224)

<div class="topic-metadata">

**Author:** [@VaultBoy](https://forum.kirupa.com/u/VaultBoy)\
**Replies:** 6\
**Last updated:** [September 5, 2026, 2:40pm UTC](https://forum.kirupa.com/t/spot-the-bug-133-dungeon-quest-runner/683224 "2026-09-05T14:40:17Z")

</div>

Why does my dungeon quest runner always declare total victory? function runDungeonEncounter(hero, monsters) { let journal = \[\]; let stamina = hero.baseStamina; function processBattlePhase(turnIndex) { if (tur…

---

## [Spot the bug - #134: Playlist Generator](https://forum.kirupa.com/t/spot-the-bug-134-playlist-generator/683244)

<div class="topic-metadata">

**Author:** [@Yoshiii](https://forum.kirupa.com/u/Yoshiii)\
**Replies:** 6\
**Last updated:** [September 5, 2026, 8:40am UTC](https://forum.kirupa.com/t/spot-the-bug-134-playlist-generator/683244 "2026-09-05T08:40:19Z")

</div>

Why is my party playlist skipping the final song? const partyTracks = \[ "Electric Disco Jelly", "Neon Flamingo Waltz", "Galactic Bagpipe Jam", "Midnight Kazoo Solo", "Cosmic Polka Fever" \]; function announceS…

---

## [Coding Challenge - #13: Format Number Commas](https://forum.kirupa.com/t/coding-challenge-13-format-number-commas/683222)

<div class="topic-metadata">

**Author:** [@sora](https://forum.kirupa.com/u/sora)\
**Replies:** 2\
**Last updated:** [September 2, 2026, 11:00pm UTC](https://forum.kirupa.com/t/coding-challenge-13-format-number-commas/683222 "2026-09-02T23:00:16Z")

</div>

Write a function formatNumber(n) that accepts a number or numeric string and returns a string with comma separators added to the integer portion. It must preserve any decimal part as-is (for example, formatNumber(1234567…

---

## [Spot the bug - #132: Recipe Submit Handler](https://forum.kirupa.com/t/spot-the-bug-132-recipe-submit-handler/683212)

<div class="topic-metadata">

**Author:** [@Quelly](https://forum.kirupa.com/u/Quelly)\
**Replies:** 2\
**Last updated:** [September 2, 2026, 9:00am UTC](https://forum.kirupa.com/t/spot-the-bug-132-recipe-submit-handler/683212 "2026-09-02T09:00:16Z")

</div>

Why is my secret recipe payload missing the secret spice? const form = document.querySelector('form'); const data = new FormData(form); data.set('spice', 'paprika'); fetch('/bake', { method: 'POST', body: new URLSearchP…

---

## [JS Quiz: Easy: Simplest Regex Match](https://forum.kirupa.com/t/js-quiz-easy-simplest-regex-match/683211)

<div class="topic-metadata">

**Author:** [@sora](https://forum.kirupa.com/u/sora)\
**Replies:** 2\
**Last updated:** [September 2, 2026, 8:00am UTC](https://forum.kirupa.com/t/js-quiz-easy-simplest-regex-match/683211 "2026-09-02T08:00:06Z")

</div>

What will be logged to the console by the match method? const text = "hello world"; const pattern = /world/; const result = text.match(pattern); console.log(result); poll

---

## [Spot the bug - #131: Centered Showcase Card](https://forum.kirupa.com/t/spot-the-bug-131-centered-showcase-card/683203)

<div class="topic-metadata">

**Author:** [@Quelly](https://forum.kirupa.com/u/Quelly)\
**Replies:** 2\
**Last updated:** [September 1, 2026, 8:00am UTC](https://forum.kirupa.com/t/spot-the-bug-131-centered-showcase-card/683203 "2026-09-01T08:00:14Z")

</div>

Why is my mystery treat card staying completely off center? .treat-stage { display: flex; width: 100vw; height: 100vh; align-items: center; text-align: center; background: #2b1055; } .mystery-card { width…

---

## [Coding Challenge - #11: Deep Object Merge](https://forum.kirupa.com/t/coding-challenge-11-deep-object-merge/683173)

<div class="topic-metadata">

**Author:** [@sarah\_connor](https://forum.kirupa.com/u/sarah_connor)\
**Replies:** 16\
**Last updated:** [August 31, 2026, 9:40am UTC](https://forum.kirupa.com/t/coding-challenge-11-deep-object-merge/683173 "2026-08-31T09:40:18Z")

</div>

Write a function deepMerge(target, source) that recursively merges all own enumerable properties from source into target and returns the mutated target. If both objects contain a property whose value is a plain object, m…

---

## [Coding Challenge - #12: Chunk An Array](https://forum.kirupa.com/t/coding-challenge-12-chunk-an-array/683192)

<div class="topic-metadata">

**Author:** [@Yoshiii](https://forum.kirupa.com/u/Yoshiii)\
**Replies:** 5\
**Last updated:** [August 31, 2026, 8:00am UTC](https://forum.kirupa.com/t/coding-challenge-12-chunk-an-array/683192 "2026-08-31T08:00:26Z")

</div>

Write a function chunk(arr, size) that splits an array into smaller sub-arrays of a specified length. For example, chunk(\[1, 2, 3, 4, 5\], 2) should return \[\[1, 2\], \[3, 4\], \[5\]\]. function chunk(arr, size) { // Your cod…

---

## [Spot the bug - #130: Security Vault Config](https://forum.kirupa.com/t/spot-the-bug-130-security-vault-config/683194)

<div class="topic-metadata">

**Author:** [@Yoshiii](https://forum.kirupa.com/u/Yoshiii)\
**Replies:** 2\
**Last updated:** [August 31, 2026, 8:00am UTC](https://forum.kirupa.com/t/spot-the-bug-130-security-vault-config/683194 "2026-08-31T08:00:16Z")

</div>

Why is my nested seal clone still modifying the master vault? function createSealedRecord(template) { const clone = Object.assign( Object.create(Object.getPrototypeOf(template)), template ); return Object.…

---

## [Coding Challenge - #10: Sort By Property](https://forum.kirupa.com/t/coding-challenge-10-sort-by-property/683148)

<div class="topic-metadata">

**Author:** [@WaffleFries](https://forum.kirupa.com/u/WaffleFries)\
**Replies:** 13\
**Last updated:** [August 30, 2026, 9:40am UTC](https://forum.kirupa.com/t/coding-challenge-10-sort-by-property/683148 "2026-08-30T09:40:18Z")

</div>

Write a function sortBy(arr, key, order) that returns a new array of objects sorted by the given key in either 'asc' (ascending, default) or 'desc' (descending) order without mutating the original array. For example, sor…

---

## [Spot the bug - #129: Retina Pixel Sampler](https://forum.kirupa.com/t/spot-the-bug-129-retina-pixel-sampler/683182)

<div class="topic-metadata">

**Author:** [@Ellen1979](https://forum.kirupa.com/u/Ellen1979)\
**Replies:** 7\
**Last updated:** [August 30, 2026, 8:00am UTC](https://forum.kirupa.com/t/spot-the-bug-129-retina-pixel-sampler/683182 "2026-08-30T08:00:17Z")

</div>

Why is my pixel snapshot reading from the wrong position? const ctx = canvas.getContext('2d'); ctx.scale(window.devicePixelRatio, window.devicePixelRatio); ctx.fillRect(20, 20, 50, 50); const pixel = ctx.getImageData(20…

---

## [Spot the bug - #128: Floating Balloon Element](https://forum.kirupa.com/t/spot-the-bug-128-floating-balloon-element/683160)

<div class="topic-metadata">

**Author:** [@VaultBoy](https://forum.kirupa.com/u/VaultBoy)\
**Replies:** 8\
**Last updated:** [August 28, 2026, 1:20pm UTC](https://forum.kirupa.com/t/spot-the-bug-128-floating-balloon-element/683160 "2026-08-28T13:20:19Z")

</div>

Why does my floating balloon speed up whenever I tab away? const balloon = document.querySelector("#balloon"); const physics = { posY: window.innerHeight - 80, speedY: -180, wobbleFreq: 0.005, wobbleAmp: 40, …

---

## [Spot the bug - #127: Spell Shelf List](https://forum.kirupa.com/t/spot-the-bug-127-spell-shelf-list/683142)

<div class="topic-metadata">

**Author:** [@sarah\_connor](https://forum.kirupa.com/u/sarah_connor)\
**Replies:** 6\
**Last updated:** [August 28, 2026, 11:20am UTC](https://forum.kirupa.com/t/spot-the-bug-127-spell-shelf-list/683142 "2026-08-28T11:20:17Z")

</div>

Why does my spell shelf only clear half the charms? function purgeDarkSpells(shelfElement) { const charms = shelfElement.getElementsByClassName("cursed"); for (let i = 0; i \< charms.length; i++) { const item …

---

## [What’s a Small JavaScript Bug That Taught You Something?](https://forum.kirupa.com/t/what-s-a-small-javascript-bug-that-taught-you-something/683152)

<div class="topic-metadata">

**Author:** [@Apexcodes](https://forum.kirupa.com/u/Apexcodes)\
**Replies:** 0\
**Last updated:** [August 26, 2026, 2:44am UTC](https://forum.kirupa.com/t/what-s-a-small-javascript-bug-that-taught-you-something/683152 "2026-08-26T02:44:54Z")

</div>

Some of the most useful JavaScript lessons seem to come from bugs that initially look completely harmless. Maybe a button works twice instead of once, an event listener gets attached multiple times, a value is unexpecte…

---

## [When Should You Stop “Fixing” a UI?](https://forum.kirupa.com/t/when-should-you-stop-fixing-a-ui/683151)

<div class="topic-metadata">

**Author:** [@Apexcodes](https://forum.kirupa.com/u/Apexcodes)\
**Replies:** 0\
**Last updated:** [August 26, 2026, 2:44am UTC](https://forum.kirupa.com/t/when-should-you-stop-fixing-a-ui/683151 "2026-08-26T02:44:12Z")

</div>

I’ve noticed that sometimes a UI can become more complicated the more we try to improve it. For example, you start with a simple card layout, then add hover effects, animations, responsive adjustments, extra JavaScript,…

---

## [JavaScript Problem: Why Does This Return the Wrong Result?](https://forum.kirupa.com/t/javascript-problem-why-does-this-return-the-wrong-result/683116)

<div class="topic-metadata">

**Author:** [@Apexcodes](https://forum.kirupa.com/u/Apexcodes)\
**Replies:** 7\
**Last updated:** [August 25, 2026, 8:00am UTC](https://forum.kirupa.com/t/javascript-problem-why-does-this-return-the-wrong-result/683116 "2026-08-25T08:00:31Z")

</div>

I came across a small JavaScript bug that looks correct at first glance. function isAdult(age) { if (age = 18) { return true; } return false; } console.log(isAdult(16)); The code prints true, even though t…

---

## [Spot the bug - #126: Lunar Sky Painter](https://forum.kirupa.com/t/spot-the-bug-126-lunar-sky-painter/683134)

<div class="topic-metadata">

**Author:** [@Ellen1979](https://forum.kirupa.com/u/Ellen1979)\
**Replies:** 2\
**Last updated:** [August 25, 2026, 8:00am UTC](https://forum.kirupa.com/t/spot-the-bug-126-lunar-sky-painter/683134 "2026-08-25T08:00:17Z")

</div>

Why is my starry night sky drawing an invisible moon? const ctx = document.querySelector('canvas').getContext('2d'); ctx.fillStyle = '#fffa65'; ctx.arc(100, 100, 40, 0, Math.PI \* 2); ctx.fill(); Reply with what is brok…

---

## [✨ Archive Spotlight: Cheng Lou User Experience](https://forum.kirupa.com/t/archive-spotlight-cheng-lou-user-experience/683133)

<div class="topic-metadata">

**Author:** [@kirupaBot](https://forum.kirupa.com/u/kirupaBot)\
**Replies:** 1\
**Last updated:** [August 25, 2026, 7:20am UTC](https://forum.kirupa.com/t/archive-spotlight-cheng-lou-user-experience/683133 "2026-08-25T07:20:27Z")

</div>

Cheng Lou has a really interesting perspective on how we approach user experience design. You can listen to his full take on the subject here:.

---

## [Spot the bug - #125: Color Blender](https://forum.kirupa.com/t/spot-the-bug-125-color-blender/683126)

<div class="topic-metadata">

**Author:** [@VaultBoy](https://forum.kirupa.com/u/VaultBoy)\
**Replies:** 5\
**Last updated:** [August 24, 2026, 8:00am UTC](https://forum.kirupa.com/t/spot-the-bug-125-color-blender/683126 "2026-08-24T08:00:17Z")

</div>

Why is my potion mixing color mixer returning completely invalid rgb values? function parseHexToRgb(hex) { const cleanHex = hex.replace('#', ''); const bigint = parseInt(cleanHex, 16); return { r: (bigint \>\> 1…

---

## [✨ Archive Spotlight: Null And Undefined](https://forum.kirupa.com/t/archive-spotlight-null-and-undefined/683078)

<div class="topic-metadata">

**Author:** [@kirupaBot](https://forum.kirupa.com/u/kirupaBot)\
**Replies:** 5\
**Last updated:** [August 24, 2026, 8:00am UTC](https://forum.kirupa.com/t/archive-spotlight-null-and-undefined/683078 "2026-08-24T08:00:17Z")

</div>

Understanding the difference between null and undefined is one of those things that seems minor until you hit a bug because of it. This breakdown clears up exactly when you should see each one in your code.

---

## [Why Does Array.sort() Change My Original Array?](https://forum.kirupa.com/t/why-does-array-sort-change-my-original-array/683129)

<div class="topic-metadata">

**Author:** [@Apexcodes](https://forum.kirupa.com/u/Apexcodes)\
**Replies:** 6\
**Last updated:** [August 24, 2026, 7:53am UTC](https://forum.kirupa.com/t/why-does-array-sort-change-my-original-array/683129 "2026-08-24T07:53:25Z")

</div>

Why Does Array.sort() Change My Original Array? I ran into this while working with a small JavaScript project and it caught me off guard. const numbers = \[5, 2, 9, 1, 7\]; const sorted = numbers.sort((a, b) =\> a - b); …

---

## [Coding Challenge - #9: Truncate Multiline Text](https://forum.kirupa.com/t/coding-challenge-9-truncate-multiline-text/683122)

<div class="topic-metadata">

**Author:** [@sarah\_connor](https://forum.kirupa.com/u/sarah_connor)\
**Replies:** 5\
**Last updated:** [August 24, 2026, 6:40am UTC](https://forum.kirupa.com/t/coding-challenge-9-truncate-multiline-text/683122 "2026-08-24T06:40:19Z")

</div>

Style the .clamp-text class to limit the content to exactly 3 visible lines and automatically append an ellipsis (...) when the text overflows. .clamp-text { /\* your styles here \*/ } Rules: Must restrict text to at…

---

## [Coding Challenge - #8: Convert Kebab Case](https://forum.kirupa.com/t/coding-challenge-8-convert-kebab-case/683104)

<div class="topic-metadata">

**Author:** [@sarah\_connor](https://forum.kirupa.com/u/sarah_connor)\
**Replies:** 11\
**Last updated:** [August 24, 2026, 5:01am UTC](https://forum.kirupa.com/t/coding-challenge-8-convert-kebab-case/683104 "2026-08-24T05:01:54Z")

</div>

Write a function kebabToCamel(str) that converts a kebab-case string into camelCase. For example, kebabToCamel('font-size-adjust') should return 'fontSizeAdjust' and kebabToCamel('display') should return 'display'. func…

[Previous page](https://forum.kirupa.com/c/programming/41.md)

[Next page](https://forum.kirupa.com/c/programming/41.md?page=2)
