JSFiddle - React, Tailwind, and code Playground

by dmitri_pavlutin

JavaScript

function isDense(array) {
  for (let index = 0; index < array.length; index++) {
    if (!(index in array)) {
      return false;
    }
  }
  return true;
}

const names = ['Batman', 'Joker', 'Bane'];
console.log(isDense(names)); // logs true