I have an object having key-value pairs. Another array has only a partial set of keys. I want a third array that contains only values and that too only for those keys which are present in the second array.
let x= {'Hello':'Monday', 'World':'Tuesday', 'Program':'Wednesday'}
let y = ['Program','Hello']
What I require in output is :
y=['Wednesday', 'Monday']
Try This
let x= {'Hello':'Monday', 'World':'Tuesday', 'Program':'Wednesday'}
let y = ['Program','Hello']
console.log(y.map(val => x[val]));