10 Javascript Exercises with Objects
Continuing the idea of ten exercises for arrays, I made a collection of tasks for objects. Like the previous one, this collection is oriented for junior and middle javascript developers.
For every task, I will provide a description, expected result, and solution. I do not claim every solution is the best approach to solve the exercises, but I hope it eventually would help you to improve your skills.
Also, I would like to mention that I won’t handle all the error cases, like passing undefined, null, or wrong data types, I provide a basic solution, not writing a library for production.
You can start in your repository or clone mine. In that repository, you can find a full list of exercises and solutions. Also, you can easily check your solutions with pre-created tests. Link: https://github.com/andrewborisov/javascript-practice.
- isPlainObject - Write a method that verifies an argument is a plain object, not an array or null
/**
* Task description: Write a method that verifies an argument is a plain object, not an array or null
* Expected Result: True if object is plain, false otherwise.
({ a: 1 }) => true,
([1, 2, 3]) => false
* Task complexity: 1 of 5
* @param element - element to verify
* @returns {boolean}
*/
export const isPlainObject = (element) => {
throw…