Iam getting console output as [object HTMLLIElement]

function render()
    {
       value="";
       b="";

       for(i=0;i<link.length;i++)
        {
          value=document.createElement("li");
          value.innerText=link[i];
          b+=value;
        }  
       console.log(b);
    }

I want the output to be li … li li….li but my output is [object HTMLLIElement] can anyone guide?

>Solution :

when you append value to the variable b

value is DOM object

so if you want the string for HTML you can use outerHTML property

function render()
    {
       value="";
       b="";

       for(i=0;i<link.length;i++)
        {
          value=document.createElement("li");
          value.innerText=link[i];
          b+=value.outerHTML;
        }  
       console.log(b);
    }

One thought on “Iam getting console output as [object HTMLLIElement]

Leave a Reply