A Clever Way To Read A Lot Quickly

Report a typo

Hey there! This problem might be a bit unpredictable, but give it a go and let us know how you do!

A programmer decided to write a JavaScript function that would parse all the package.json files of his workspace to check for specific properties automatically. In order to do that, he needs your help to write a helper function that is used to check if the JSON data that is now an object is a workspace or not. He also needs to check the number of dependencies, devDependencies and peerDependancies. The function should return an array with the data in the order:

  1. true or false if workspace.

  2. number of dependencies

  3. number of devDependencies

  4. number of peerDependencies

Here is an example.

const data = [true, 3, 4, 5]

Sample Input 1:

Sample Output 1:

true
Write a program in JavaScript
function checkPackageJson(data) {
// Complete this function, enter code here


return [];
}

Create a free account to access the full topic