JavaScript Objects | Exercises, Practice and Solutions

5/5 - (1 vote)

In this post, I set out to add problems with JavaScript objects that I find interesting. Are problems of simple or medium difficulty, but which have the role of helping you learn how to work better with objects.

Therefore, I invite you to post problems that you liked with Javascript objects in the comments.

If you want to learn more about Objects and Classes in JavaScript, find here All about JavaScript Objects and Classes

1. Count of the total number of objects obj satisfying obj.x == obj.y.

I fount this problem on HackerRank, 10 days of JavaScript
1. An array of objects is given.
2. Each object in the array has two integer properties: x and y
3. Count the total number of objects obj satisfying obj.x == obj.y.

My solution:

function getCount(objects) {
    let arrayItems = objects.filter((item) => {
        return item.x == item.y;
    return arrayItems.length;

Hello there!

I hope you find this post useful!

I'm Mihai, a programmer and online marketing specialist, very passionate about everything that means online marketing, focused on eCommerce.

If you have a collaboration proposal or need helps with your projects feel free to contact me. I will always be glad to help you!

subscribe youtube

Leave a Comment