remove null from array javascript
let array = [0, 1, null, 2, 3];
function removeNull(array) {
return array.filter(x => x !== null)
};
remove null from array javascript
let array = [0, 1, null, 2, 3];
function removeNull(array) {
return array.filter(x => x !== null)
};
how to skip the undefined values from the list and filter the rest of the data in react js
let shops = [
{
name: 'shop1',
tags: ['s', 'd', 'f'],
country: 'rda'
},
{
name: 'shop2',
tags: ['e', 'd', 'r'],
country: 'ke'
},
{
name: 'shop3',
tags: ['p', 'u', 'i'],
country: 'rda'
},
{
name: 'shop4',
tags: ['a', 'k', 'l'],
country: 'bu'
}
]
function getRdaShops(){
retun shops.map(sh=>{
if(sh.name && sh.country==='rda') return sh.name
}).filter(sh=>sh!==undefined)
}
//Answer: ['shop1', 'shop3']
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us