JavaScript Interview Solved Problems
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)]
console.log(temp2)
for(let i=0;i
Comments
Post a Comment