JSFiddle - React, Tailwind, and code Playground

by Jake Overall

JavaScript

/*
* reduce the following array to show only items that are inStock
*/

var store = [
  { name: 'Goldfish', inStock: true, },
  { name: 'Golden Retriver', inStock: true, },
  { name: 'Aligator', inStock: false, },
  { name: 'Goat', inStock: true, }];

for(var i = 0; i < store.length; i++){
    if(!store[i].inStock){
        store.splice(i, 1);
        i--;
    }
}