Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arrays -> Question #9 #110

Open
avadhutprabhudesai opened this issue Aug 9, 2022 · 0 comments
Open

Arrays -> Question #9 #110

avadhutprabhudesai opened this issue Aug 9, 2022 · 0 comments

Comments

@avadhutprabhudesai
Copy link

The answer should be
[2,'12',true] [2,'12',true] [2,0,false,'12', true] [2,0,false,'','12', true]

In the question code snippet, containers is being modified before each filter operation.

Kindly modify the code as following and cross check the answer

(function(){
	var containers = [2,0,false,"", '12', true];
	var containers1 = containers.filter(Boolean);
	console.log(containers1);
	var containers2 = containers.filter(Number);
	console.log(containers2);
	var containers3 = containers.filter(String);
	console.log(containers3);
	var containers4 = containers.filter(Object);
	console.log(containers4);		
})();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant