+ 1

Object.entries not working

Why isn’t this code logging anything? I asked chatgpt and it says it should work. Is it a sololearn playground thing? https://sololearn.com/compiler-playground/WLx71EpV4726/?ref=app

29th Apr 2025, 11:35 PM
Zvi
Zvi - avatar
2 Antworten
+ 3
Zvi it is working. you just have to format the result to make it easier to understand. function Obj(q,w,e){ this.q=q; this.w=w; this.e=e; this.meth=function(){ console.log(this.q+this.e) } } let obj1=new Obj("p","o","i"); let a = Object.entries(obj1); for (const [k,v] of a){ console.log(`${k}: ${v}`); }
30th Apr 2025, 12:59 AM
Bob_Li
Bob_Li - avatar
+ 2
Bob_Li Thanks!👍
30th Apr 2025, 2:07 AM
Zvi
Zvi - avatar