2
I want to concatenate a sum of a number to a string in Javascript and had to resort to an auxiliary variable.
What I did first (incorrect example):
for (var i; i < x; i++)
h = "texto" + x+1 + ".txt";
Afterward:
for (var i; i < x; i++){
var a = i+1;
h = "texto" + a + ".txt";
}
Any solution for me to avoid that auxiliary variable?
Note: This is not the code I’m working with at the moment, it’s just to illustrate my problem. The exchange solution i++
for ++i
, does not apply in my case.
Have you tried this?
"texto" + (x+1) + ".txt"
– Maniero
No --', thanks mustache
– lazyFox
In both versions you’re using the
x
differently. You can explain the role ofx
in the question?– Sergio
Take a look at [tour]. You can accept an answer if it solved your problem. You can vote on every post on the site as well. Did any help you more? You need something to be improved?
– Maniero