Object comparision problem
1. Question 1 You have given following input object values as input 1 and input 2 and you have to calculate output as object which has matching key value pairs const input1={a:1, b:2, c:5, d:10, e:12} const input2= {a:3, b:5, d:10,e:12} const output = {b:10,e:12} Solution. const input1={a:1, b:2, c:5, d:10, e:12} const input2= {a:3, b:5, d:10,e:12} // const output = {b:10,e:12} const getCommonValues=()=>{ let output={} let temp1=[Object.keys(input1), Object.values(input1)] let temp2= [Object.keys(input2), Object.values(input2)] for(let i=0;i< temp1[0].length;i++){ for(let j=0; j < temp2[0].length; j++){ if(temp1[0][i]===temp2[0][j] && temp1[1][i]===temp2[1][j]){ output[temp1[0][i]]=temp1[1][i] }}}return output} console.log(getCommonValues())