/    Sign up×
Community /Pin to ProfileBookmark

concatenating char and numbers

hello,

I’m trying to make this kind of string (without quotes):
“c00″,”c01”, etc…
yet when I use this code:

[CODE]for(i=0;i<8;i++){
a = toString(‘c’+parseInt(10+i));
b = toString(‘c’+parseInt(60+i));
document.images[a].src = “images/pawn_”+oclr+”.gif”;
document.images[b].src = “images/pawn_”+clr+”.gif”;
}
[/CODE]

it doesn’t seem to work out as expected…

what’s wrong with my code?

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@FangDec 23.2005 — a = 'c'+parseInt(10+i);
Copy linkTweet thisAlerts:
@CharlesDec 23.2005 — a = 'c' + (10 + 1)
Copy linkTweet thisAlerts:
@konithomimoDec 23.2005 — Like Charles said,

a = 'c' + (10 + i)

you only have to use parseInt if you are taking in a value from an object, not if you declare a variable equal to an integer.
Copy linkTweet thisAlerts:
@FangDec 23.2005 — a = 'c' + (10 + [B][COLOR=Red]i[/COLOR][/B])
Copy linkTweet thisAlerts:
@X-rayauthorDec 23.2005 — k

i had figured it out already but thanx guys ?
×

Success!

Help @X-ray 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.15,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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