I'm really new to this and as such my terminology is probably poor, ask me for clarification if you need. Sorry if this is a basic question. Here's an example of my problem:
var post1title = "example title 1";
var post1text = "example text 1";
var post2title = "example title 2";
var post2text = "example text 2";
function update() {
setText("titleBox", post1title);
setText("bodyBox", post1text);
My goal is to make the function update() have a parameter that allows the text in a text box to be either, for example, post1title or post2title.
I'd like to do something similar to what you do with strings when variables are involved, as shown here:
console.log("User has set the variable post1title to: " + post1title);
// prints "User has set the variable post1title to: example title 1" to the debug console
It doesn't seem like you can do the same thing when calling variables, though. I've tried doing the same as you would with strings (where "n" is a number 1-2):
var post1title = "example title 1";
var post1text = "example text 1";
var post2title = "example title 2";
var post2text = "example text 2";
function update(n) {
setText("titleBox", post + n + title);
setText("bodyBox", post + n + text);
This obviously reads as adding three variables together. Is something like this possible?