PAWDD E-Training
11May/100

Balancing Parenthesis and Brackets (Equally Paired)

How to Balance Braces and Parenthesis

Making sure your braces and Parenthesis are always paired with one another properly, you can use a simple counting technique.

Starting at the initial parenthesis OR brace in the series, "starting from ZERO" for every"("OR "{" add one to the initial count of ZERO. For every "(" OR "}" subtract ONE from your ongoing count.

Do as follows:

Open: "(" OR "{" = plus 1 OR = +1 such as starting at ZERO 0+1 = 1")"
OR
Close: ")"OR "}" = minus 1 OR = -1 such as starting at ONE 1-1= 0

Start at zero = (some code 1)+(some( code)) || ((some)( code3)) = 0
Brace 1 is#1 = +1.............-1..+1...+1....-1-1...+1+1..-1+1...-1-1 = 0
Actual count = 1...............0....1.....2.......1.0....1.2.....1.2.....1..0 = 0

Remember we started at zero prior to counting anything and added and subtracted for every parenthisis character, starting with the initial one. Our final count ended up being ZERO if our brackets are balanced.

Dreamweaver CS5 now offers the ability to count the braces or parenthesis for you, and notify you of your mistake.

Comments (0) Trackbacks (7904)

No comments yet.


Leave a comment

You must be logged in to post a comment.

jobs
Apple iPhone 6