Dynamically remove arrays from multidimensional array

Hi,

  1. Please format your code when you post it. You were told how to do this here.
  2. I would seriously consider using an array of objects as your data structure. This was suggested here.

You can use Array.filter.
Ref.: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter

Here is an example:

let radiators = [
  [200, 30, 'kitchen'],
  [150, 60, 'living room'],
  [90, 40, 'bathroom'],
  [120, 60, 'bedroom']
];

radiators = radiators.filter(radiator => ! radiator.includes('kitchen') );
console.log(radiators);

HTH

3 Likes