To find the highest value in an object in JavaScript, you can use the `Object.values`

method to extract the values of the object into an array and then use the `Math.max`

method to find the highest value.

Here’s an example:

```
const object = {
a: 1,
b: 2,
c: 3,
d: 4
};
const values = Object.values(object);
const highestValue = Math.max(...values);
console.log(highestValue); // Output: 4
```

In this example, the `Object.values`

method is used to extract the values of the object `{ a: 1, b: 2, c: 3, d: 4 }`

into an array `[1, 2, 3, 4]`

. The spread operator (`...`

) is used to pass the values of the array as separate arguments to the `Math.max`

method, which returns the highest value, which is `4`

in this case.

## + There are no comments

Add yours