简体   繁体   中英

variable inside another variable

hi there i wanted to put this:

document.write("y = " + i);

inside another variable, like this:

s=s+"\"y = \" \+ i";

but now, i variable is not variable, just a plain text.

how can i fix this? output would be

document.getElementById("output").innerHTML=s;

thank you

You do not pass to s string a variable - just text i . Try with:

s=s+"y = " + i;

You can also convert it to:

s += "y = " + i;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM