Please enable JavaScript to use CodeHS

CodeHS Glossary


Parentheses General

Open parens: `(` Close parens: `)` ---------- You often need to use parentheses to group things in code. Here are a few examples of when you use them. When calling a function, you need to write an open and close parens `()` after it. e.g. `putBall();` When writing an if statement or while loop, you need parentheses to show what is inside it. e.g. if (condition) { Remember: if your condition is a function (like in Karel), you need parentheses after that as well. Make sure to include *all* the parentheses. if (frontIsClear()) { Notice how there is the `())` at the end. The first `)` ends the `(` for `frontIsClear` and the second `)` ends the if statement. You need parentheses when writing a for loop. You also use parentheses to group order of operations. e.g. 3 * 4 + 1 // => 13 3 * (4 + 1) // => 15 ---------- To type parentheses, hold the `SHIFT` key and press the `9` or `0` key.