0% found this document useful (0 votes)
2 views3 pages

CodeHS JavaScript MC Study Code

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)
2 views3 pages

CodeHS JavaScript MC Study Code

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. Variable Declaration & Data Types


let name = 'Alice'; // string

let age = 16; // number

let isStudent = true; // boolean

2. Input/Output
let name = readLine("Enter your name: ");

let age = readInt("Enter your age: ");

println("Hello, " + name);

3. Arithmetic Operators
let sum = 5 + 3;

let diff = 10 - 4;

let prod = 6 * 2;

let div = 12 / 3;

let mod = 10 % 3;

4. If, Else If, Else


if (score >= 90) {

println("A");

} else if (score >= 80) {

println("B");

} else {

println("C or below");

5. While and For Loops


// While loop:

let i = 0;

while (i < 5) {

println(i);
CodeHS JavaScript Exam Study Notes

i++;

// For loop:

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

println(j);

6. Functions
function greet() {

println("Hello!");

greet();

7. Graphics - Shapes
let circle = new Circle(40);

[Link](100, 100);

[Link]([Link]);

add(circle);

8. Text & Images


let label = new Text("Hi", "20pt Arial");

[Link](100, 50);

add(label);

let img = new WebImage("url_here");

[Link](0, 0);

add(img);

9. Events (Mouse & Keyboard)


CodeHS JavaScript Exam Study Notes

mouseClickMethod(handleClick);

function handleClick(e) {

println("Clicked");

keyDownMethod(handleKey);

function handleKey(e) {

println([Link]);

10. Randomizer
let num = [Link](1, 10);

let color = [Link]();

11. Arrays
let nums = [10, 20, 30];

println(nums[0]); // prints 10

for (let i = 0; i < [Link]; i++) {

println(nums[i]);

12. Timers & Animation


setTimer(update, 40);

function update() {

[Link](1, 0);

You might also like