Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save drhisham-code/b186db5ecb6671151880419babd9ae2a to your computer and use it in GitHub Desktop.

Select an option

Save drhisham-code/b186db5ecb6671151880419babd9ae2a to your computer and use it in GitHub Desktop.
filter js array to only truthy values
let truthyAndFalsy = [4, 56, 78, 99, 101, 150, 299, 300,"",undefined];
let onlyTruthy =truthyAndFalsy.filter(number => Boolean(number));
console.log(onlyTruthy)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment