can multidimensions array return in function to display the all value in the 2dimentions array ??
function display(arr) {
}
const result = display([
["str", 1],
["str2", 2],
["str3", 3]
])
const result2 = display([
["str", 1],
["str2", 2],
["str3", 3],
["str4", 4]
])
const result3 = display([
["str", 1],
["str2", 2]
])
console.log(result)
console.log(result2)
console.log(result3)
i know console.log might work, how about return it in function ?
the output i want it // str = 1, str2 = 2, str3 = 3
// str = 1, str2 = 2, str3 = 3 , str4 = 4
// str = 1, str2 = 2
return arr.map(([str, value]) => str + " = " + value).join(", ");return arr.map((v) => v[1]);displayhandle the logging itself, so instead ofreturning a string that you need to log yourself later, just callconsole.logdirectly insidedisplay. Unless of course you want to use the resulting string elsewhere.