/    Sign up×
Community /Pin to ProfileBookmark

Photo Album Help

I am trying to build a photo album for my web site. I found a photo album that I like but it needs some modifications. I am not one of them people who just play around with something until it works, for this reason I want to understand how the photo album works. Any how, I am slowly understanding the code; just need some help with a bit of the logic.

Var dimension = “4×1”

Var totalslots = dimension.split(“x”)[0]* dimension.split(“x”)[1]

Ok my questions: I get everything else but what does the zero, [0] after (“x”) do?
Likewise what does the [1] after (“x”) do?

What does an exclamation point “!” mean in JavaScript?
What does a question mark “?” mean in JavaScript?

Thank you, with all my respect

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@bimmerboy91May 25.2006 — try going here for the operators (the "!" and "?"):

[URL=http://www.w3schools.com/js/js_operators.asp]Javascript Operators[/URL]
Copy linkTweet thisAlerts:
@mrhooMay 25.2006 — you are splitting the string '4x1'on the x, getting an array: ['4','1'];


dimension[0] is the first element

dimension [1] is the second

Seems like someone is pulling your leg.
Copy linkTweet thisAlerts:
@coolmanauthorMay 25.2006 — ok it get it thank you, i found "!" not Operator, but what does "?" do? thanks agian.
Copy linkTweet thisAlerts:
@bimmerboy91May 25.2006 — ok it get it thank you, i found "!" not Operator, but what does "?" do? thanks agian.[/QUOTE]

Towards the bottom of the page i linked to you will find Conditional Operators:

Conditional Operator

JavaScript also contains a conditional operator that assigns a value to a variable based on some condition.

Syntax

variablename=(condition)?value1:value2

Example

greeting=(visitor=="PRES")?"Dear President ":"Dear "

If the variable visitor is equal to PRES, then put the string "Dear President " in the variable named greeting. If the variable visitor is not equal to PRES, then put the string "Dear " into the variable named greeting.[/QUOTE]
×

Success!

Help @coolman 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 6.17,
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: @nearjob,
tipped: article
amount: 1000 SATS,

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

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