0% found this document useful (0 votes)
3 views2 pages

CodeHS JavaScript Study Notes

Uploaded by

denishui126
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

CodeHS JavaScript Study Notes

Uploaded by

denishui126
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

CodeHS JavaScript Exam Study Notes

1. Variables & Data Types


Use var or let to declare variables.

Example: let name = 'Alice';

Types: string, number, boolean

2. Input & Output


Use print() or println() to output.

Use readLine() or readInt() to get user input.

3. Arithmetic Operators
Addition (+), Subtraction (-), Multiplication (*), Division (/), Modulus (%)

4. If Statements
Basic conditionals: if, else if, else

Example:

if (x > 10) {

println('Big');

5. Loops
while loop: runs while condition is true

for loop: used for counting

Example:

for (let i = 0; i < 5; i++) {

println(i);

6. Functions
Use functions to organize code

Example:

function sayHi() {
CodeHS JavaScript Exam Study Notes

println('Hi');

7. Graphics
Use rectangles, circles, text, images

Example:

var circle = new Circle(40);

[Link](100, 100);

add(circle);

8. Mouse & Key Events


mouseClickMethod(functionName);

keyDownMethod(functionName);

9. Randomizer
[Link](min, max) for random numbers

10. Arrays
let nums = [1, 2, 3];

Access with nums[0]

Loop through with for loop

11. Animation with Timers


Use setTimer(update, 40); to animate

Call update function repeatedly

You might also like