CodeHS Unit 3 Programming With JavaScript

0.0(0)
studied byStudied by 0 people
GameKnowt Play
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/74

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

75 Terms

1
New cards

Code

A way to conveying info as symbols

2
New cards

Code is just ______ that have meaning when read in a _______ way

symbols, predefined

3
New cards

Program/Software

Computer-readable code

4
New cards

Types of code (5)

color code

genetic code

morse code

natural language

computer program

5
New cards

In order for us to give computers instructions, we need to to provide instructions in a __________ ___________.

programming language

6
New cards

Each key and mouse click generates a unique _______ (input) that gets sent to the computer. A program then processes the _______ to figure out what to do with them. The program then outputs more ________ that tell the computer to do certain things.

number(s)

7
New cards

All numbers sent as inputs and output to and from a computer are represented using ____ and _____.

0s and 1s

8
New cards

A special program called the compiler takes care of converting our _________ into the ...

program, binary machine code

9
New cards

At a high level, computer programs really just implement ___________

algorithms

10
New cards

Algorithm

A self-contained, step by step set of instructions to solve a problem

11
New cards

_________ implement algorithms

programs

12
New cards

Programs put algorithms into a _______ _________ form

computer executable

13
New cards

How to print "Hello World"

knowt flashcard image
14
New cards

A ________ is like a box that can hold a value

variable

15
New cards

Declaring a variable

(does not enter a value into the variable)

<p>(does not enter a value into the variable)</p>
16
New cards

Initializing a variable

Declares a variable and sets its initial value

<p>Declares a variable and sets its initial value</p>
17
New cards

Assigning to a variable

Changing a variable's value

18
New cards

Types of Variables

Number

Boolean

String

19
New cards

Numeric Variables - Integers

Whole numbers

<p>Whole numbers</p>
20
New cards

Numeric Variables - Floats

Real numbers (can be decimals)

<p>Real numbers (can be decimals)</p>
21
New cards

Boolean Variables

true/false

<p>true/false</p>
22
New cards

String Variable

Text (goes between quotes)

<p>Text (goes between quotes)</p>
23
New cards

Variable names start with... (3)

a letter

$

_

24
New cards

Variables Example

knowt flashcard image
25
New cards

Functions used to receive user inputs

knowt flashcard image
26
New cards

Use readLine to get/read ... from the user

strings of text

<p>strings of text</p>
27
New cards

Use readInt to get/read ____ from the user

integers

<p>integers</p>
28
New cards

Use readFLoat to get/read ____ from the user

floats (real numbers)

<p>floats (real numbers)</p>
29
New cards

User input Example

knowt flashcard image
30
New cards

Arithmetic Operators in JavaScript

knowt flashcard image
31
New cards

When a modulus operator is used, it...

divides the two numbers and takes the remainder

32
New cards

Math in JavaScript Example #1

knowt flashcard image
33
New cards

Shortcut for adding and subtracting 1 from a variable

knowt flashcard image
34
New cards

How is the coordinate system oriented for the programming canvas?

knowt flashcard image
35
New cards

The function ____________ gets the width of the canvas

getWidth()

36
New cards

The function ____________ gets the height of the canvas

getHeight()

37
New cards

How to make text located at a certain location

knowt flashcard image
38
New cards

How to make a circle centered at a certain location

knowt flashcard image
39
New cards

How to make a rectangle located at a certain location

knowt flashcard image
40
New cards

When setting the position of rectangles, the position is set at the ________________ of the graphic

top left corner

41
New cards

When setting the position of text, the position is set at the ________________ of the graphic

bottom left corner

42
New cards

Graphics example (8 ball)

knowt flashcard image
43
New cards

Mouse event

When the user does something with the mouse, like clicking or moving

44
New cards

To respond to a mouse click, we use _______ functions

callback

45
New cards

Callback function

A function passed as a parameter to another function in order to be called later. (drawCircle)

<p>A function passed as a parameter to another function in order to be called later. (drawCircle)</p>
46
New cards

When the mouse is clicked, whatever function was passed to ____________ is called

mouseClickMethod

<p>mouseClickMethod</p>
47
New cards

e is an __________ ___________ and can be any variable. We may sometimes use the variable ____________

input parameter, event

48
New cards

e stores information about ...

a mouse/key event

49
New cards

To get the x ant y positions of a click, use...

knowt flashcard image
50
New cards

Click to add a circle example

knowt flashcard image
51
New cards

Key Event Functions

knowt flashcard image
52
New cards

Functions to detect which key is pressed

knowt flashcard image
53
New cards

Moving graphic with keys

knowt flashcard image
54
New cards

What is the proper function to call to print to the screen?

println

55
New cards

What keyword do you need to use to define a variable in JavaScript?

var

56
New cards

What function do you need to call to ask the user of the program to enter text?

readLine

57
New cards

To ask the user of the program for a number, which function should you use?

Both readInt and readFloat are for numbers.

58
New cards

Question in image

What is your name? Karel

Hello Karel

<p>What is your name? Karel</p><p>Hello Karel</p>
59
New cards

Question in image

Welcome! ‎¡Hola! ‎¡Hola! Bonjour!

<p>Welcome! ‎¡Hola! ‎¡Hola! Bonjour!</p>
60
New cards

Question in image

Enter a character. P

: c P

<p>Enter a character. P</p><p>: c P</p>
61
New cards

What will the following code print to the screen?

println(2 + 2);

4

62
New cards

What symbol do you use to do division in JavaScript?

/

63
New cards

What symbol do you use to do multiplication in JavaScript?

*

64
New cards

29

<p>29</p>
65
New cards

4

<p>4</p>
66
New cards

10

<p>10</p>
67
New cards

2

<p>2</p>
68
New cards

Suppose we've written a function drawCircle that we want to call every time the mouse is clicked. How can we do this?

mouseClickMethod(drawCircle);

69
New cards

function start(){

keyDownMethod(animate);

}

<p>function start(){</p><p>keyDownMethod(animate);</p><p>}</p>
70
New cards

Why are computer programs an example of code?

Computer programs are an example of code because programmers use the different programming languages as predefined symbols to communicate with a computer.

71
New cards

Interactive

allowing the flow of information both ways between a computer and its user (with inputs and outputs)

72
New cards

Why is it important for computer programs to display information to users?

It is important for computer programs to display information to users so that the users are aware of the effects of their inputs and the status of either themselves or the computer. For example, it is important for there to be an error message when a user logs in incorrectly so that the user knows that they are not able to gain access because their username/password is wrong.

73
New cards

Why might variables be useful in our programs?

Variables might be useful in our programs to store certain values and allow the values to be easily referenced/recalled later in the program using the variable names

74
New cards

Why is it useful for programs to be able to accept user input?

It is useful for programs to be able to accept user input so the user can both access their personal information/account and so the user can have a personalized experience within the application. For instance, a person enters their login information into a program in order to access their account within the application.

75
New cards

Why is it useful for programs to be able to perform mathematical computations?

It is useful for programs to be able to perform mathematical computations so that the human using the program does not have to waste time calculating the answer themself or lack confidence in the accuracy of their answer since the computer solves the computation much quicker and more accurately. (Math computation programs are especially useful when the math calculation is complex and/or time consuming.)