I need to create an array based on some selection of keys inside an existing constant javascript object
const EXISTING_CONSTANT_OBJECT = {
'fr': '10',
'es': '15'
'us': '10'
'uk': '7'
//and so on for many other iso country codes and UNPREDICTABLE key names
}
I need to be able to create an array (without modifying EXISTING_CONSTANT_OBJECT for immutability reasons) with all keys whose value are equal to 10.
For example, the expected output is
object_to_create_arr = ["fr","us"]
I tried using reduce but failed.
note: I can use ES6 and usually prefer as it's usually more concise.
let arrayOfKeys = Object.keys( yourObject )