Sign in
Log inSign up

filter method in javascript

Default profile photo
Anonymous
·Oct 12, 2018
let observers1 =[1,2,3,5];
let a1=9;
let a2=9;
var c =[];
let observers = observers1.filter(function(item){
  if(a1 === a2) {
    c.push(item);
    return "hello";
  }
});

In the above code snippets, I am trying to return 'hello' ,for every iteration but I am getting observers1 array element values

Hassle-free blogging platform that developers and teams love.
  • Docs by Hashnode
    New
  • Blogs
  • AI Markdown Editor
  • GraphQL APIs
  • Open source Starter-kit

© Hashnode 2024 — LinearBytes Inc.

Privacy PolicyTermsCode of Conduct