# How can I find remaining percentages if one or two percentages are known

Consider the following Objects:

```// Example 1

{
}
```
```// Example 2

{
}
```
```// Example 3

{
}
```

They represent a percentage, i.e. the sum of all three grades will be exactly 100. How can we interpolate the keys with `'No-Data'` whenever their values can be calculated?

Expected Results:

```// Example 1

{
}
```
```// Example 2

{
}
```
```// Example 3

{
}

// Note: This one can't be figured out so we leave it as is.
```

My solution in pseudo-code:

```function interpolate(obj) {
// If only one key is a number:
//    The value is 100:
//        Set the other two keys to 0 and return the obj.
//    The value is less than 100:
//        return obj unchanged.
// If only one key is not a number:
//    set that key to the sum of the two numbers minus 100 and return the obj.
}
```

There are two main questions here:

1. How do I find out how many and which keys are `'No-Data'.`
2. Can I rearrange the control flow to be more efficient?

In reality, these Objects are inside an Array, but I’m sure I can figure that stuff out myself.

1. You can use something like this to filter for a key given a value (in your case `No-Data`).
`let keys = Object.keys(obj).filter(k=>obj[k]===value);`
1. Your control flow is fine, it will be readable and its efficiency depends on how efficient you are at counting the number of occurances of `No-Data`. Tip: If you are trying to be as efficient as possible, you don’t need to keep finding occurrences of `No-Data` after you find 2 ðŸ™‚