/    Sign up×
Community /Pin to ProfileBookmark

Very basic JavaScript question

Sorry for actually asking this as it’s a ridiculously simple problem, but I’m brand new to JavaScript.
I know how to do what I want to in ActionScript, but I’m not sure what the syntax is to accomplish it in JavaScript.
In ActionScript I’ve written a chunk of code that looks something like this:

[I]var currentNumber = 1;
var picture1Video = ” firstVideo.jpg”;
var picture2Video = ” secondVideo.jpg”;

placeHolder1.loadMovie(this[“picture”+(currentNumber)+”video”])

currentNumber++;

placeHolder2.loadMovie(this[“picture”+(currentNumber)+”video”])[/I]

So basically I’m incrimenting currentNumber to change what variable placeHolder1 and placeHolder2 are looking at.

How do I write that in Javascript, so that a variable name being called is made up of a string and the contents of another variable, like [“picture”+currentNumber+”video”] ?

Cheers for any help!

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @sairus spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.4,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...