DevSupporter
DevSupporter

Welcome back

Please enter your details to sign in to your account

Forgot password?
Sign in

2048

Array ManipulationMerge LogicIntermediate

Coming Soon

Game play area will be implemented here

Swipe to move tiles. When two tiles with the same number touch, they merge into one.

2D array manipulation with merge logic that combines adjacent equal values.

function mergeRow(row) {
  const filtered = row.filter(x => x);
  for (let i = 0; i < filtered.length - 1; i++) {
    if (filtered[i] === filtered[i + 1]) {
      filtered[i] *= 2;
      filtered.splice(i + 1, 1);
    }
  }
  return filtered;
}

2026 ยฉ DevSupporter - Playground for Developers by DevSupporter