The interviewer was bad, it was held in Microsoft teams, and the interview duration was 30 minutes.
He started with the basic introduction, and then told me to open any JS compiler.
He gave me an infinitely nested JSON and told me to write a function that would flatten this JSON and print the keys along with maintaining the parent's hierarchy, and their value
For example:
const inputJson = {
"phone": 123,
"person": {
"name": "ABC",
"age" : 22,
"address" : {
"current" : {
"city" : "ABC",
},
"permanent" : {
"city" : "XYZ",
},
}
}
}
and the required output would be something like
outputJson = {
phone: 123,
person.name: "ABC",
person.age: 22,
person.address.current.city : "ABC",
person.address.permanent.city: "XYZ"
}
I started writing a recursive function, but meanwhile writing the code I had some doubts so I asked the questions, he didn't respond. I asked him again and said "Hello", "can you hear me" two three times, then he responded that "are you saying something?", I repeated my question.
In the end I was able to write the recursive function that would return the JSON in the desired format, but I took almost 35 minutes to do it.
I said, "I think this is the function, it is giving the result in the correct format",
again he didn't respond, I went to the tab where the call was ongoing, the guy already dropped. He didn't even say a word in the middle of the interview, he just dropped.