Link to home
Start Free TrialLog in
Avatar of juan field
juan field

asked on

how can i remove string values

function removeStringValues(obj) {
  for(var key in obj){
      if(obj[key] === String){
          delete obj[key];
      }
  }
}

var obj = {
  name: 'Sam',
  age: 20
};
removeStringValues(obj);
console.log(obj); // { age: 20 }
ASKER CERTIFIED SOLUTION
Avatar of Elvio Lujan
Elvio Lujan
Flag of Argentina image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of juan field
juan field

ASKER

because i wasnt using the typeof it was comparing data sets . Thank you!!!!!!!