I want to add values to a variable inside a for as follows:
function gerarcods(){
var alfa = $("#nalfa").val();
var qtdcods = $("#nqtdcods").val();
codigos = "";
for(i = 1; i<= qtdcods; i++){
str = alfa+i+",";
res = codigos.concat(str);
}
}
However, in this way, the value of res is superimposed (obviously). The intention is that the string looks like this: "alpha1, alpha2, alpha3 ...". I would like to know if there is a function to add a content to the string without losing it's previous value.