JavaScript:Filter
by Farzad Cyrus
CSS
html {
margin: 0;
padding: 0;
font-size: 62.5%;
}
body {
background: #202731;
color: #aaa;
padding: 3.2rem;
font-size: 1.6rem;
font-family: sans-serif;
line-height: 2.4rem;
}
JavaScript
var state = {
successful: true,
lastUpdate: {
date: '25/10/2017',
time: '23:15'
},
instance: [
{
id: 101,
name: 'Reillustrate'
},
{
id: 167,
name: 'Typify'
},
{
id: 145,
name: 'StylishWeb'
}
]
};
function log(data) {
const body = document.querySelector('body');
body.innerHTML += JSON.stringify(data);
}
const condition = 'START';
switch(condition) {
case 'START':
const instance = state.instance.filter(el => {
return el.id === 101;
});
log(instance)
break;
}
log('<br>__________<br>');
log(state);