I want to print elements of the following array of objects
const questions = [{
'Q1':[0, 1, 2 , 3]
},{
'Q2': ['true','false']
},{
'Q3': ['none']
}];
I want it to print 'Q1' then its elements then 'Q2' and so on
I need them to be separated but in the same order
Q1 => 0 => 1 => 2 => 3
Q2 => true => false
Q3 => none
What is the best way to achieve this?
Array.join()
to convert the arrays to strings separated by=>
. Loop over the object properties, using that on each value.