How to avoid undefined in string concatenation?

后端 未结 2 2154
无人共我
无人共我 2021-01-18 23:17

I\'m iterating over an object and I want to concatenate the name of the service. This is my code:

var servizi;

for(var i = 0; i < appointment.id_services         


        
2条回答
  •  孤独总比滥情好
    2021-01-19 00:02

    You get undefined because you declared an uninitialized variable, and then added to it (twice).

    Initialize the declared variable as an empty string first

    var servizi = "";
    

提交回复
热议问题