Message from JavaScript discussions

November 2020

— But since it exposes an async iterable it becomes very simple to work with

— 

Hi!
I'm a little bit confusing with TS.
I have a object like:
{
platform: 'minikube',
installer: 'olm',
telemtry: 'on',
namespace: 'some-ns',
pmn:false
}
and I need to create a object which contain : installer, platform properties.(Filter from orignal one)
Can someone help to do it in the best way, please?

— Const itemLevelData = [
{
scenarioid: 'Current',
product: 'LIMESTONE',
productgroup: 'RM',
date: '',
status: '',
servicelevel: '0.99',
budget: '100K',
inventorylevels: '',
safetystock: '',
},
{
scenarioid: 'Scenario-1',
product: 'LIMESTONE',
productgroup: 'RM',
date: '08/18/2020',
status: 'Completed',
servicelevel: '0.98',
budget: '80K',
inventorylevels: '20K',
safetystock: '1K',
},
{
scenarioid: 'Scenario-2',
product: 'LIMESTONE',
productgroup: 'RM',
date: '09/18/2020',
status: 'Completed',
servicelevel: '0.94',
budget: '50K',
inventorylevels: '2K',
safetystock: '200',
},
{
scenarioid: 'Scenario-12',
product: 'OPC CEM',
productgroup: 'FG',
date: '06/20/2020',
status: 'Completed',
servicelevel: '0.96',
budget: '70K',
inventorylevels: '25K',
safetystock: '2K',
},
{
scenarioid: 'Scenario-21',
product: 'OPC CEM',
productgroup: 'FG',
date: '07/20/2020',
status: 'Completed',
servicelevel: '0.94',
budget: '60K',
inventorylevels: '2K',
safetystock: '200',
},
{
scenarioid: 'Scenario-14',
product: 'LIQUID FUEL',
productgroup: 'FUEL',
date: '04/28/2020',
status: 'Completed',
servicelevel: '0.95',
budget: '60K',
inventorylevels: '23K',
safetystock: '1.5K',
},
{
scenarioid: 'Scenario-17',
product: 'LIQUID FUEL',
productgroup: 'FUEL',
date: '05/28/2020',
status: 'Completed',
servicelevel: '0.94',
budget: '50K',
inventorylevels: '2K',
safetystock: '150',
},
]

const scenario = ['Scenario-1','Scenario-2']


I need to filter the itemLevelData such that I should contain objects that has scenarioid starting with scenario1x and scenario2x

Message permanent page

— Scenario1, Scenario12, Scenario14, Scenario17 are sub scenarios for Scenario1.

— Sounds like you want Pick

— Thank you

— Yes

— Filter by scenarioid.includes()

— Tried that. But not working.

— Share what you have

— itemLevelData.filter(i => scenario.includes(i.slice(0, -1)))

— Why -1?